GodziLaravel's avatar

How to login then go to specific link to test ?

Hello ,

In my test I would like to login as user then get specific url status !

    public function test_links()
    {

        $this->post('/login', [
            'email'     => '[email protected]',
            'password'  => 'password',
        ])
            ->get('/myprofile')
            ->assertStatus(200);


    }
0 likes
6 replies
GodziLaravel's avatar

@sergiu17 Is it possible to specify more attributes in user model when ->create() ?

For example I want to specify that is _admin is true and other attributes too ?

GodziLaravel's avatar

@sergiu17 thanks it works

Is it possible act like a user without create method ? I mean by existing user ?

Sergiu17's avatar

@mostafalaravel yes, but is bad practice to do test on your production database

public function test_links()
{
    $user = App\User::find($id); // $id is placeholder, App\User::find(1)

    $this->actingAs($user);
}

Please or to participate in this conversation.