vendredi 14 août 2020

Laravel testing. Is possible to use multiple calls in same test?

I have this test:

public function test_user_can_access_the_application_page(  
{
        $user=[
            'email'=>'user@user.com',
            'password'=>'user1234',
        ];

        $response=$this->call('POST','/login',$user);
        $this->assertAuthenticated();
        $response->assertStatus(302)
            ->assertRedirect('/dashboard')
            ->assertLocation('/dashboard');
        $response=$this->call('GET','/application/index');
        $response->assertLocation('/application/index');
}

After I log in, it directs me to the dashboard ok until now, but if I want to access the other page after that, I cant. This error comes up.

Expected :'https://ift.tt/3iGqUcZ'

Actual :'http://mock.test'

Aren't multiple calls allowed in the same test, or is another way to access other pages after login? (Note: It's not possible to use factories for the actingAs so I need to login).

Aucun commentaire:

Enregistrer un commentaire