createOne(); static::assertIsString($artist->searchableAs()); } /** * Artist shall be a searchable resource. * * @return void */ public function testToSearchableArray(): void { $artist = Artist::factory()->createOne(); static::assertIsArray($artist->toSearchableArray()); } /** * Artists shall be nameable. * * @return void */ public function testNameable(): void { $artist = Artist::factory()->createOne(); static::assertIsString($artist->getName()); } /** * Artists shall have subtitle. * * @return void */ public function testHasSubtitle(): void { $artist = Artist::factory()->createOne(); static::assertIsString($artist->getSubtitle()); } /** * Artist shall have a many-to-many relationship with the type Song. * * @return void */ public function testSongs(): void { $songCount = $this->faker->randomDigitNotNull(); $artist = Artist::factory() ->has(Song::factory()->count($songCount)) ->createOne(); static::assertInstanceOf(BelongsToMany::class, $artist->songs()); static::assertEquals($songCount, $artist->songs()->count()); static::assertInstanceOf(Song::class, $artist->songs()->first()); static::assertEquals(ArtistSong::class, $artist->songs()->getPivotClass()); } /** * Artist shall have a many-to-many relationship with the type ExternalResource. * * @return void */ public function testExternalResources(): void { $resourceCount = $this->faker->randomDigitNotNull(); $artist = Artist::factory() ->has(ExternalResource::factory()->count($resourceCount), 'resources') ->createOne(); static::assertInstanceOf(BelongsToMany::class, $artist->resources()); static::assertEquals($resourceCount, $artist->resources()->count()); static::assertInstanceOf(ExternalResource::class, $artist->resources()->first()); static::assertEquals(ArtistResource::class, $artist->resources()->getPivotClass()); } /** * Artist shall have a many-to-many relationship to the type Artist as "members". * * @return void */ public function testMembers(): void { $memberCount = $this->faker->randomDigitNotNull(); $artist = Artist::factory() ->has(Artist::factory()->count($memberCount), 'members') ->createOne(); static::assertInstanceOf(BelongsToMany::class, $artist->members()); static::assertEquals($memberCount, $artist->members()->count()); static::assertInstanceOf(Artist::class, $artist->members()->first()); static::assertEquals(ArtistMember::class, $artist->members()->getPivotClass()); } /** * Artist shall have a many-to-many relationship to the type Artist as "groups". * * @return void */ public function testGroups(): void { $groupCount = $this->faker->randomDigitNotNull(); $artist = Artist::factory() ->has(Artist::factory()->count($groupCount), 'groups') ->createOne(); static::assertInstanceOf(BelongsToMany::class, $artist->groups()); static::assertEquals($groupCount, $artist->groups()->count()); static::assertInstanceOf(Artist::class, $artist->groups()->first()); static::assertEquals(ArtistMember::class, $artist->groups()->getPivotClass()); } /** * Artist shall have a many-to-many relationship with the type Image. * * @return void */ public function testImages(): void { $imageCount = $this->faker->randomDigitNotNull(); $artist = Artist::factory() ->has(Image::factory()->count($imageCount)) ->createOne(); static::assertInstanceOf(BelongsToMany::class, $artist->images()); static::assertEquals($imageCount, $artist->images()->count()); static::assertInstanceOf(Image::class, $artist->images()->first()); static::assertEquals(ArtistImage::class, $artist->images()->getPivotClass()); } }