createOne(); $this->assertIsString($studio->searchableAs()); }); test('to searchable array', function () { $studio = Studio::factory()->createOne(); $this->assertIsArray($studio->toSearchableArray()); }); test('nameable', function () { $studio = Studio::factory()->createOne(); $this->assertIsString($studio->getName()); }); test('has subtitle', function () { $studio = Studio::factory()->createOne(); $this->assertIsString($studio->getSubtitle()); }); test('anime', function () { $animeCount = fake()->randomDigitNotNull(); $studio = Studio::factory() ->has(Anime::factory()->count($animeCount)) ->createOne(); $this->assertInstanceOf(BelongsToMany::class, $studio->anime()); $this->assertEquals($animeCount, $studio->anime()->count()); $this->assertInstanceOf(Anime::class, $studio->anime()->first()); $this->assertEquals(AnimeStudio::class, $studio->anime()->getPivotClass()); }); test('external resources', function () { $resourceCount = fake()->randomDigitNotNull(); $studio = Studio::factory() ->has(ExternalResource::factory()->count($resourceCount), 'resources') ->createOne(); $this->assertInstanceOf(MorphToMany::class, $studio->resources()); $this->assertEquals($resourceCount, $studio->resources()->count()); $this->assertInstanceOf(ExternalResource::class, $studio->resources()->first()); $this->assertEquals(Resourceable::class, $studio->resources()->getPivotClass()); }); test('images', function () { $imageCount = fake()->randomDigitNotNull(); $studio = Studio::factory() ->has(Image::factory()->count($imageCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $studio->images()); $this->assertEquals($imageCount, $studio->images()->count()); $this->assertInstanceOf(Image::class, $studio->images()->first()); $this->assertEquals(Imageable::class, $studio->images()->getPivotClass()); });