mercredi 4 novembre 2015

User Authentication in Unit Testing Laravel 5.1

I'm a bit confused about the unit testing in Laravel 5.1.

I want to test the updating of settings from a user account. I'm using phpunit for testing.

This is my test case.

/** @test */
    public function it_updates_personal_details(){

        $this->withoutMiddleware();
        $this->visit('/account/settings')
            ->post('/account/settings', ["firstname"=>"RingoUpdated", 'lastname'=>"RingyUpdated", "username"=>"ringo", "bio"=>"My Personal Information", "facebook"=>"myFbUsername", "twitter"=>"myTwUsername", ])
            ->seeJson([
                "signup"=>true
            ]);
    }

But in my controller, I'm using Auth::id() to get the current logged in user's id. How can I mock this in Laravel 5.1 ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire