diff --git a/ai/backend_prompt_template.md b/ai/backend_prompt_template.md index c8d0edf..c16ef26 100644 --- a/ai/backend_prompt_template.md +++ b/ai/backend_prompt_template.md @@ -20,6 +20,9 @@ Code patterns to follow: - Entities: constructor with properties, getters - DTOs: simple data containers for creation - Repositories: interfaces that define data access + - Do not write unit tests for concrete repository implementations + (e.g., Doctrine/persistence-backed). They are exercised by e2e + tests. Use cases are tested with fake repositories. - Use cases: business logic with Request objects - When throwing exceptions, add @throws docblock - Fakes: in-memory implementations for testing diff --git a/tests/Unit/Auth/FakeSessionRepositoryTest.php b/tests/Unit/Auth/FakeSessionRepositoryTest.php deleted file mode 100644 index 6e2bce4..0000000 --- a/tests/Unit/Auth/FakeSessionRepositoryTest.php +++ /dev/null @@ -1,68 +0,0 @@ -sessionRepo = new FakeSessionRepository(); - } - - public function test_create_and_find_by_token(): void - { - $this->sessionRepo->create(new CreateSessionDto( - token: 'abc123', - userId: 0, - createdAt: new DateTimeImmutable('2025-01-01'), - expiresAt: new DateTimeImmutable('2025-01-08'), - )); - - $session = $this->sessionRepo->findByToken('abc123'); - - $this->assertInstanceOf(Session::class, $session); - $this->assertEquals('abc123', $session->getToken()); - $this->assertEquals(0, $session->getUserId()); - } - - public function test_find_by_token_returns_null_when_missing(): void - { - $this->assertNull($this->sessionRepo->findByToken('nope')); - } - - public function test_find_by_token_returns_fresh_instance(): void - { - $created = $this->sessionRepo->create(new CreateSessionDto( - token: 'abc123', - userId: 0, - createdAt: new DateTimeImmutable('2025-01-01'), - expiresAt: new DateTimeImmutable('2025-01-08'), - )); - - $fetched = $this->sessionRepo->findByToken('abc123'); - - $this->assertNotSame($created, $fetched); - } - - public function test_delete_by_token(): void - { - $this->sessionRepo->create(new CreateSessionDto( - token: 'abc123', - userId: 0, - createdAt: new DateTimeImmutable('2025-01-01'), - expiresAt: new DateTimeImmutable('2025-01-08'), - )); - - $this->sessionRepo->deleteByToken('abc123'); - - $this->assertNull($this->sessionRepo->findByToken('abc123')); - } -} diff --git a/tests/Unit/User/FakeUserRepositoryTest.php b/tests/Unit/User/FakeUserRepositoryTest.php deleted file mode 100644 index 4df07f0..0000000 --- a/tests/Unit/User/FakeUserRepositoryTest.php +++ /dev/null @@ -1,52 +0,0 @@ -create(new CreateUserDto( - email: new EmailAddress('test@test.com'), - passwordHash: '', - )); - - $user = $userRepo->findByEmail(new EmailAddress('test@test.com')); - - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('test@test.com', $user->getEmail()->value()); - } - - public function test_find_by_email_returns_null_when_not_found(): void - { - $userRepo = new FakeUserRepository(); - - $user = $userRepo->findByEmail( - new EmailAddress('missing@test.com') - ); - - $this->assertNull($user); - } - - public function test_find_by_email_returns_fresh_instance(): void - { - $userRepo = new FakeUserRepository(); - $created = $userRepo->create(new CreateUserDto( - email: new EmailAddress('test@test.com'), - passwordHash: '', - )); - - $fetched = $userRepo->findByEmail( - new EmailAddress('test@test.com') - ); - - $this->assertNotSame($created, $fetched); - } -}