for(Artist::factory()) ->for(ExternalResource::factory(), 'resource') ->createOne(); static::assertInstanceOf(BelongsTo::class, $artistResource->artist()); static::assertInstanceOf(Artist::class, $artistResource->artist()->first()); } /** * An ArtistResource shall belong to an ExternalResource. * * @return void */ public function testResource(): void { $artistResource = ArtistResource::factory() ->for(Artist::factory()) ->for(ExternalResource::factory(), 'resource') ->createOne(); static::assertInstanceOf(BelongsTo::class, $artistResource->resource()); static::assertInstanceOf(ExternalResource::class, $artistResource->resource()->first()); } }