makeOne(); $response = $this->post(route('api.song.store', $song->toArray())); $response->assertUnauthorized(); } /** * The Song Store Endpoint shall forbid users without the create song permission. * * @return void */ public function testForbidden(): void { $song = Song::factory()->makeOne(); $user = User::factory()->createOne(); Sanctum::actingAs($user); $response = $this->post(route('api.song.store', $song->toArray())); $response->assertForbidden(); } /** * The Song Store Endpoint shall create a song. * * @return void */ public function testCreate(): void { $parameters = Song::factory()->raw(); $user = User::factory()->withPermissions(CrudPermission::CREATE->format(Song::class))->createOne(); Sanctum::actingAs($user); $response = $this->post(route('api.song.store', $parameters)); $response->assertCreated(); static::assertDatabaseCount(Song::class, 1); } }