createOne(); $site = $resource->site; static::assertInstanceOf(ResourceSite::class, $site); } /** * Resources shall be nameable. * * @return void */ public function testNameable(): void { $resource = ExternalResource::factory()->createOne(); static::assertIsString($resource->getName()); } /** * Resources shall have subtitle. * * @return void */ public function testHasSubtitle(): void { $resource = ExternalResource::factory()->createOne(); static::assertIsString($resource->getSubtitle()); } /** * Resource shall have a many-to-many relationship with the type Anime. * * @return void */ public function testAnime(): void { $animeCount = $this->faker->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Anime::factory()->count($animeCount)) ->createOne(); static::assertInstanceOf(BelongsToMany::class, $resource->anime()); static::assertEquals($animeCount, $resource->anime()->count()); static::assertInstanceOf(Anime::class, $resource->anime()->first()); static::assertEquals(AnimeResource::class, $resource->anime()->getPivotClass()); } /** * Resource shall have a many-to-many relationship with the type Artist. * * @return void */ public function testArtists(): void { $artistCount = $this->faker->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Artist::factory()->count($artistCount)) ->createOne(); static::assertInstanceOf(BelongsToMany::class, $resource->artists()); static::assertEquals($artistCount, $resource->artists()->count()); static::assertInstanceOf(Artist::class, $resource->artists()->first()); static::assertEquals(ArtistResource::class, $resource->artists()->getPivotClass()); } /** * Resource shall have a many-to-many relationship with the type Song. */ public function testSong(): void { $songCount = $this->faker->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Song::factory()->count($songCount)) ->createOne(); static::assertInstanceOf(BelongsToMany::class, $resource->songs()); static::assertEquals($songCount, $resource->songs()->count()); static::assertInstanceOf(Song::class, $resource->songs()->first()); static::assertEquals(SongResource::class, $resource->songs()->getPivotClass()); } /** * Resource shall have a many-to-many relationship with the type Studio. * * @return void */ public function testStudio(): void { $studioCount = $this->faker->randomDigitNotNull(); $resource = ExternalResource::factory() ->has(Studio::factory()->count($studioCount)) ->createOne(); static::assertInstanceOf(BelongsToMany::class, $resource->studios()); static::assertEquals($studioCount, $resource->studios()->count()); static::assertInstanceOf(Studio::class, $resource->studios()->first()); static::assertEquals(StudioResource::class, $resource->studios()->getPivotClass()); } }