createOne(); $site = $resource->site; $this->assertInstanceOf(ResourceSite::class, $site); }); test('nameable', function () { $resource = ExternalResource::factory()->createOne(); $this->assertIsString($resource->getName()); }); test('has subtitle', function () { $resource = ExternalResource::factory()->createOne(); $this->assertIsString($resource->getSubtitle()); }); test('anime', function () { $animeCount = fake()->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Anime::factory()->count($animeCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $resource->anime()); $this->assertEquals($animeCount, $resource->anime()->count()); $this->assertInstanceOf(Anime::class, $resource->anime()->first()); $this->assertEquals(Resourceable::class, $resource->anime()->getPivotClass()); }); test('anime theme entry', function () { $entryCount = fake()->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(AnimeThemeEntry::factory()->forAnime()->count($entryCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $resource->animethemeentries()); $this->assertEquals($entryCount, $resource->animethemeentries()->count()); $this->assertInstanceOf(AnimeThemeEntry::class, $resource->animethemeentries()->first()); $this->assertEquals(Resourceable::class, $resource->animethemeentries()->getPivotClass()); }); test('artists', function () { $artistCount = fake()->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Artist::factory()->count($artistCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $resource->artists()); $this->assertEquals($artistCount, $resource->artists()->count()); $this->assertInstanceOf(Artist::class, $resource->artists()->first()); $this->assertEquals(Resourceable::class, $resource->artists()->getPivotClass()); }); test('song', function () { $songCount = fake()->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Song::factory()->count($songCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $resource->songs()); $this->assertEquals($songCount, $resource->songs()->count()); $this->assertInstanceOf(Song::class, $resource->songs()->first()); $this->assertEquals(Resourceable::class, $resource->songs()->getPivotClass()); }); test('studio', function () { $studioCount = fake()->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Studio::factory()->count($studioCount)) ->createOne(); $this->assertInstanceOf(MorphToMany::class, $resource->studios()); $this->assertEquals($studioCount, $resource->studios()->count()); $this->assertInstanceOf(Studio::class, $resource->studios()->first()); $this->assertEquals(Resourceable::class, $resource->studios()->getPivotClass()); });