repository = new ConsoleRepository(new Console()); } #[Test] public function it_gets_all_consoles_with_games_count(): void { Console::factory()->count(3)->create(); $consoles = $this->repository->getAll(); $this->assertCount(3, $consoles); } #[Test] public function it_gets_console_by_slug(): void { $console = Console::factory()->create(['slug' => 'nes']); $found = $this->repository->getBySlug('nes'); $this->assertNotNull($found); $this->assertEquals($console->id, $found->id); } #[Test] public function it_returns_null_for_nonexistent_slug(): void { $found = $this->repository->getBySlug('nonexistent'); $this->assertNull($found); } #[Test] public function it_gets_consoles_with_games_count(): void { $console = Console::factory()->create(); Game::factory()->count(5)->create(['console_id' => $console->id]); $consoles = $this->repository->getWithGamesCount(); $this->assertCount(1, $consoles); $this->assertEquals(5, $consoles->first()->games_count); } }