repository = new RomFileRepository(new RomFile()); } #[Test] public function it_counts_rom_files(): void { $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); RomFile::factory()->count(5)->create(['game_id' => $game->id]); $this->assertEquals(5, $this->repository->count()); } #[Test] public function it_finds_by_hash(): void { $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); $romFile = RomFile::factory()->create([ 'game_id' => $game->id, 'file_hash' => 'abc123', ]); $found = $this->repository->findByHash('abc123'); $this->assertNotNull($found); $this->assertEquals($romFile->id, $found->id); } #[Test] public function it_returns_null_for_nonexistent_hash(): void { $found = $this->repository->findByHash('nonexistent'); $this->assertNull($found); } #[Test] public function it_creates_a_rom_file(): void { $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); $romFile = $this->repository->create([ 'game_id' => $game->id, 'file_path' => 'roms/nes/game.nes', 'file_name' => 'game.nes', 'file_size' => 102400, 'file_hash' => 'abc123', ]); $this->assertDatabaseHas('rom_files', ['file_hash' => 'abc123']); } #[Test] public function it_gets_rom_files_by_game(): void { $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); RomFile::factory()->count(3)->create(['game_id' => $game->id]); $otherGame = Game::factory()->create(['console_id' => $console->id]); RomFile::factory()->count(2)->create(['game_id' => $otherGame->id]); $romFiles = $this->repository->getByGame($game->id); $this->assertCount(3, $romFiles); } }