first(); $role = Role::factory()->create(); $role->permissions()->attach($permission->id); $user = User::factory()->create(); $user->roles()->attach($role->id); Sanctum::actingAs($user); $data = Role::factory()->create(); $response = $this->post('/auth/role/'.$data->id,[ "name" => "update role", ]); $response->assertStatus(200); $response->assertJson([ "data" => [ "name" => "update role", ] ]); } /** * A basic feature test example. */ public function test_with_roles_success(): void { $permission = Permission::where("code","auth.role:update")->first(); $role = Role::factory()->create(); $role->permissions()->attach($permission->id); $user = User::factory()->create(); $user->roles()->attach($role->id); Sanctum::actingAs($user); $data = Role::factory()->create(); $role2 = Role::factory()->create(); $response = $this->post('/auth/role/'.$data->id,[ "name" => "update role", "permissions" => [ $permission->id ] ]); $response->assertStatus(200); $response->assertJson([ "data" => [ "name" => "update role", "permissions" => [ [ "id" => $permission->id ] ] ] ]); } }