extract auth test fakes
This commit is contained in:
parent
ae07a6ff7c
commit
64acbfad60
6 changed files with 58 additions and 29 deletions
|
|
@ -3,36 +3,26 @@
|
|||
namespace Tests\Unit\Auth\UseCases;
|
||||
|
||||
use App\Auth\Clock;
|
||||
use App\Auth\TokenGenerator;
|
||||
use App\Auth\UseCases\CreateSession\CreateSession;
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
use App\User\User;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Tests\Fakes\FakeClock;
|
||||
use Tests\Fakes\FakeSessionRepository;
|
||||
use Tests\Fakes\FakeTokenGenerator;
|
||||
|
||||
class CreateSessionTest extends TestCase
|
||||
{
|
||||
private FakeSessionRepository $sessionRepo;
|
||||
private TokenGenerator $tokenGenerator;
|
||||
private FakeTokenGenerator $tokenGenerator;
|
||||
private Clock $clock;
|
||||
private CreateSession $createSession;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->sessionRepo = new FakeSessionRepository();
|
||||
$this->tokenGenerator = new class implements TokenGenerator {
|
||||
public function generate(): string
|
||||
{
|
||||
return 'fake-token-123';
|
||||
}
|
||||
};
|
||||
$this->clock = new class implements Clock {
|
||||
public function now(): DateTimeImmutable
|
||||
{
|
||||
return new DateTimeImmutable('2026-05-18 12:00:00', new \DateTimeZone('UTC'));
|
||||
}
|
||||
};
|
||||
$this->tokenGenerator = new FakeTokenGenerator();
|
||||
$this->clock = new FakeClock();
|
||||
|
||||
$this->createSession = new CreateSession($this->sessionRepo, $this->tokenGenerator, $this->clock);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue