create(); $this->assertInstanceOf(Console::class, $game->console); } #[Test] public function it_has_many_rom_files(): void { $game = Game::factory()->create(); RomFile::factory()->count(3)->create(['game_id' => $game->id]); $this->assertCount(3, $game->romFiles); } #[Test] public function it_has_many_save_files(): void { $game = Game::factory()->create(); SaveFile::factory()->count(2)->create(['game_id' => $game->id]); $this->assertCount(2, $game->saveFiles); } #[Test] public function it_uses_slug_as_route_key(): void { $game = new Game(); $this->assertEquals('slug', $game->getRouteKeyName()); } #[Test] public function it_auto_generates_slug_from_title_on_creating(): void { $game = Game::factory()->create([ 'title' => 'Super Mario Bros', 'slug' => null, ]); $this->assertEquals('super-mario-bros', $game->slug); } #[Test] public function it_keeps_existing_slug(): void { $game = Game::factory()->create([ 'title' => 'Super Mario Bros', 'slug' => 'custom-slug', ]); $this->assertEquals('custom-slug', $game->slug); } #[Test] public function it_casts_rating_to_decimal(): void { $game = Game::factory()->create(['rating' => 8.5]); $this->assertEquals('8.5', (string) $game->rating); } #[Test] public function it_has_fillable_attributes(): void { $game = new Game(); $this->assertEquals([ 'console_id', 'title', 'slug', 'igdb_id', 'tgdb_id', 'description', 'release_year', 'developer', 'publisher', 'genre', 'rating', 'cover_path', 'thumbnail_path', ], $game->getFillable()); } }