createOne(); $parameters = Song::factory()->raw(); $response = $this->put(route('api.song.update', ['song' => $song] + $parameters)); $response->assertUnauthorized(); } /** * The Song Store Endpoint shall forbid users without the create song permission. * * @return void */ public function testForbidden(): void { $song = Song::factory()->createOne(); $parameters = Song::factory()->raw(); $user = User::factory()->createOne(); Sanctum::actingAs($user); $response = $this->put(route('api.song.update', ['song' => $song] + $parameters)); $response->assertForbidden(); } /** * The Song Update Endpoint shall forbid users from updating a song that is trashed. * * @return void */ public function testTrashed(): void { $song = Song::factory()->trashed()->createOne(); $parameters = Song::factory()->raw(); $user = User::factory()->withPermissions(CrudPermission::UPDATE->format(Song::class))->createOne(); Sanctum::actingAs($user); $response = $this->put(route('api.song.update', ['song' => $song] + $parameters)); $response->assertForbidden(); } /** * The Song Update Endpoint shall update a song. * * @return void */ public function testUpdate(): void { $song = Song::factory()->createOne(); $parameters = Song::factory()->raw(); $user = User::factory()->withPermissions(CrudPermission::UPDATE->format(Song::class))->createOne(); Sanctum::actingAs($user); $response = $this->put(route('api.song.update', ['song' => $song] + $parameters)); $response->assertOk(); } }