create(); $this->actingAs($user) ->get(route('games.edit', 'nonexistent')) ->assertNotFound(); } public function test_game_update_returns_404_for_invalid_slug(): void { $user = User::factory()->create(); $this->actingAs($user) ->put(route('games.update', 'nonexistent'), ['title' => 'Test']) ->assertNotFound(); } public function test_game_destroy_returns_404_for_invalid_slug(): void { $user = User::factory()->create(); $this->actingAs($user) ->delete(route('games.destroy', 'nonexistent')) ->assertNotFound(); } public function test_game_can_be_deleted_with_rom_files(): void { Storage::fake('local'); $user = User::factory()->create(); $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); RomFile::factory()->create([ 'game_id' => $game->id, 'file_path' => 'roms/nes/game.nes', ]); Storage::disk('local')->put('roms/nes/game.nes', 'rom-data'); $this->actingAs($user) ->delete(route('games.destroy', $game->slug)) ->assertRedirect(); $this->assertDatabaseMissing('games', ['id' => $game->id]); } public function test_game_can_be_deleted_with_cover(): void { Storage::fake('local'); $user = User::factory()->create(); $console = Console::factory()->create(); $game = Game::factory()->create([ 'console_id' => $console->id, 'cover_path' => 'covers/nes/game-cover.jpg', ]); Storage::disk('local')->put('covers/nes/game-cover.jpg', 'cover-data'); $this->actingAs($user) ->delete(route('games.destroy', $game->slug)) ->assertRedirect(); $this->assertDatabaseMissing('games', ['id' => $game->id]); } public function test_game_download_returns_file(): void { Storage::fake('local'); $user = User::factory()->create(); $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); $romFile = RomFile::factory()->create([ 'game_id' => $game->id, 'file_path' => 'roms/nes/game.nes', 'file_name' => 'game.nes', ]); Storage::disk('local')->put('roms/nes/game.nes', 'rom-data'); $this->actingAs($user) ->get(route('games.download', [$game->slug, $romFile->id])) ->assertOk(); } public function test_game_download_returns_404_for_invalid_rom(): void { $user = User::factory()->create(); $console = Console::factory()->create(); $game = Game::factory()->create(['console_id' => $console->id]); $this->actingAs($user) ->get(route('games.download', [$game->slug, 99999])) ->assertNotFound(); } }