Expected status code 200 but received 302.

Posted 8 months ago by BishoyWagih

i'm trying to perform a test to check if 1 - the user is authenticated 2 - has permission to view the requested page

every time i run the test i get this error

Expected status code 200 but received 302.

Here is my TestMethod

 /** @test */

public function it_can_see_all_categories()
{
    $user = $user = factory(User::class)->create();
    $this->actingAs($user);

    $permission = Permission::create(['group' => 'categories' , 'name' => 'view categories' , 'label' => 'view categories']);

    $role = Role::find($user->role_id);

    $role->givePermissionTo($permission);

    $response = $this->get('/categories');

    $response->assertStatus(200 , $response->getStatusCode());
}

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.