Expected status code 200 but received 302.

Posted 4 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();

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

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


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

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

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.