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