extract auth test fakes
This commit is contained in:
parent
ae07a6ff7c
commit
64acbfad60
6 changed files with 58 additions and 29 deletions
15
backend/tests/Fakes/FakeClock.php
Normal file
15
backend/tests/Fakes/FakeClock.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Auth\Clock;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
|
||||
class FakeClock implements Clock
|
||||
{
|
||||
public function now(): DateTimeImmutable
|
||||
{
|
||||
return new DateTimeImmutable('2026-05-18 12:00:00', new DateTimeZone('UTC'));
|
||||
}
|
||||
}
|
||||
18
backend/tests/Fakes/FakeHasher.php
Normal file
18
backend/tests/Fakes/FakeHasher.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Auth\PasswordHasher;
|
||||
|
||||
class FakeHasher implements PasswordHasher
|
||||
{
|
||||
public function hash(string $password): string
|
||||
{
|
||||
return 'hashed-' . $password;
|
||||
}
|
||||
|
||||
public function verify(string $password, string $hash): bool
|
||||
{
|
||||
return $hash === 'hashed-' . $password;
|
||||
}
|
||||
}
|
||||
13
backend/tests/Fakes/FakeTokenGenerator.php
Normal file
13
backend/tests/Fakes/FakeTokenGenerator.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Auth\TokenGenerator;
|
||||
|
||||
class FakeTokenGenerator implements TokenGenerator
|
||||
{
|
||||
public function generate(): string
|
||||
{
|
||||
return 'fake-token-123';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue