createOne(); $image = Image::factory()->createOne(); $response = $this->post(route('api.artistimage.store', ['artist' => $artist, 'image' => $image])); $response->assertUnauthorized(); } /** * The Artist Image Store Endpoint shall forbid users without the create artist & create image permissions. * * @return void */ public function testForbidden(): void { $artist = Artist::factory()->createOne(); $image = Image::factory()->createOne(); $user = User::factory()->createOne(); Sanctum::actingAs($user); $response = $this->post(route('api.artistimage.store', ['artist' => $artist, 'image' => $image])); $response->assertForbidden(); } /** * The Artist Image Store Endpoint shall create an artist image. * * @return void */ public function testCreate(): void { $artist = Artist::factory()->createOne(); $image = Image::factory()->createOne(); $user = User::factory() ->withPermissions( CrudPermission::CREATE->format(Artist::class), CrudPermission::CREATE->format(Image::class) ) ->createOne(); Sanctum::actingAs($user); $response = $this->post(route('api.artistimage.store', ['artist' => $artist, 'image' => $image])); $response->assertCreated(); static::assertDatabaseCount(ArtistImage::class, 1); } }