I have make a unit test case as :
public function test_user_registration(){
$this->withoutExceptionHandling();
$this->withoutMiddleware();
Bus::fake();
$user = User::find(1);
Sanctum::actingAs($user,['*']);
$response = $this->post('/api/users',[
"firstName"=>"Kamal",
"lastName"=>"Garu",
"email"=>"Kamasll@gmail.com",
"roleId"=>[4],
"defaultRoleId"=>4,
"investorId"=>[15],
"defaultInvestorId"=>15,
"streetAddress"=>"Jalur Banj",
"postalCode"=>"977",
"city"=>"bhaktapur",
"countryId"=>160,
"phone"=>9741801138,
"status"=>1,
"emailPortfolioReport"=>0,
"emailInvestorActivities"=>0,
"emailMarketUpdate"=>1,
"isdCodeId"=>149,
"roleType"=>["investorInternational"]
]);
VerifyUser::dispatch($response);
Bus::assertDispatched(VerifyUser::class);
$response->assertStatus(200);
}
And everytime i run this code this throw error as "Illuminate\Auth\Access\AuthorizationException: not authorized " Here 1 is the id of admin so m acting as a admin user. Need Help..