Clock + SystemClock (DateTimeImmutable in UTC), TokenGenerator + RandomTokenGenerator (bin2hex(random_bytes(32)) -> 64-char hex), PasswordHasher + BcryptPasswordHasher (password_hash with PASSWORD_DEFAULT, password_verify). matching fakes: FakeClock with mutable setTime, FakeTokenGenerator with a pre-seeded queue (throws once exhausted), FakePasswordHasher returns 'hashed:<plain>' for deterministic test assertions. composer stan now passes --memory-limit=512M (default 128M overflows once larastan loads more rules).
18 lines
342 B
PHP
18 lines
342 B
PHP
<?php
|
|
|
|
namespace Tests\Fakes;
|
|
|
|
use App\Auth\PasswordHasher;
|
|
|
|
class FakePasswordHasher implements PasswordHasher
|
|
{
|
|
public function hash(string $password): string
|
|
{
|
|
return 'hashed:'.$password;
|
|
}
|
|
|
|
public function verify(string $password, string $hash): bool
|
|
{
|
|
return $this->hash($password) === $hash;
|
|
}
|
|
}
|