for(Artist::factory()) ->for(Song::factory()) ->createOne(); $parameters = ArtistSong::factory()->raw(); $response = $this->put(route('api.artistsong.update', ['artist' => $artistSong->artist, 'song' => $artistSong->song] + $parameters)); $response->assertUnauthorized(); } /** * The Artist Resource Update Endpoint shall forbid users without the update artist & update song permissions. * * @return void */ public function testForbidden(): void { $artistSong = ArtistSong::factory() ->for(Artist::factory()) ->for(Song::factory()) ->createOne(); $parameters = ArtistSong::factory()->raw(); $user = User::factory()->createOne(); Sanctum::actingAs($user); $response = $this->put(route('api.artistsong.update', ['artist' => $artistSong->artist, 'song' => $artistSong->song] + $parameters)); $response->assertForbidden(); } /** * The Artist Resource Update Endpoint shall update an artist song. * * @return void */ public function testUpdate(): void { $artistSong = ArtistSong::factory() ->for(Artist::factory()) ->for(Song::factory()) ->createOne(); $parameters = ArtistSong::factory()->raw(); $user = User::factory() ->withPermissions( CrudPermission::UPDATE->format(Artist::class), CrudPermission::UPDATE->format(Song::class) ) ->createOne(); Sanctum::actingAs($user); $response = $this->put(route('api.artistsong.update', ['artist' => $artistSong->artist, 'song' => $artistSong->song] + $parameters)); $response->assertOk(); } }