createOne(); $season = $anime->season; $this->assertInstanceOf(AnimeSeason::class, $season); }); test('casts format to enum', function (): void { $anime = Anime::factory()->createOne(); $this->assertInstanceOf(AnimeFormat::class, $anime->format); }); test('searchable as', function (): void { $anime = Anime::factory()->createOne(); $this->assertIsString($anime->searchableAs()); }); test('to searchable array', function (): void { $anime = Anime::factory()->createOne(); $this->assertIsArray($anime->toSearchableArray()); }); test('nameable', function (): void { $anime = Anime::factory()->createOne(); $this->assertIsString($anime->getName()); }); test('has subtitle', function (): void { $anime = Anime::factory()->createOne(); $this->assertIsString($anime->getSubtitle()); }); test('synonyms', function (): void { $synonymCount = fake()->randomDigitNotNull(); $anime = Anime::factory() ->has(Synonym::factory()->count($synonymCount)) ->createOne(); $this->assertInstanceOf(MorphMany::class, $anime->synonyms()); $this->assertEquals($synonymCount, $anime->synonyms()->count()); $this->assertInstanceOf(Synonym::class, $anime->synonyms()->first()); }); test('series', function (): void { $seriesCount = fake()->randomDigitNotNull(); $anime = Anime::factory() ->has(Series::factory()->count($seriesCount)) ->createOne(); $this->assertInstanceOf(BelongsToMany::class, $anime->series()); $this->assertEquals($seriesCount, $anime->series()->count()); $this->assertInstanceOf(Series::class, $anime->series()->first()); $this->assertEquals(AnimeSeries::class, $anime->series()->getPivotClass()); }); test('themes', function (): void { $themeCount = fake()->randomDigitNotNull(); $anime = Anime::factory() ->has(AnimeTheme::factory()->count($themeCount)) ->createOne(); $this->assertInstanceOf(HasMany::class, $anime->animethemes()); $this->assertEquals($themeCount, $anime->animethemes()->count()); $this->assertInstanceOf(AnimeTheme::class, $anime->animethemes()->first()); }); test('external resources', function (): void { $resourceCount = fake()->randomDigitNotNull(); $anime = Anime::factory() ->has(ExternalResource::factory()->count($resourceCount), 'resources') ->createOne(); $this->assertInstanceOf(MorphToMany::class, $anime->resources()); $this->assertEquals($resourceCount, $anime->resources()->count()); $this->assertInstanceOf(ExternalResource::class, $anime->resources()->first()); $this->assertEquals(Resourceable::class, $anime->resources()->getPivotClass()); }); test('images', function (): void { $imageCount = fake()->randomDigitNotNull(); $anime = Anime::factory() ->has(Image::factory()->count($imageCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $anime->images()); $this->assertEquals($imageCount, $anime->images()->count()); $this->assertInstanceOf(Image::class, $anime->images()->first()); $this->assertEquals(Imageable::class, $anime->images()->getPivotClass()); }); test('studios', function (): void { $studioCount = fake()->randomDigitNotNull(); $anime = Anime::factory() ->has(Studio::factory()->count($studioCount)) ->createOne(); $this->assertInstanceOf(BelongsToMany::class, $anime->studios()); $this->assertEquals($studioCount, $anime->studios()->count()); $this->assertInstanceOf(Studio::class, $anime->studios()->first()); $this->assertEquals(AnimeStudio::class, $anime->studios()->getPivotClass()); });