jeudi 24 mars 2016

Codeception: How to use amLoggedAs in a Helper class

I am trying to make a helper class for my codeception functional tests that makes it quicker to specify logging in as a super user. Here is my helper:

class Laravel5Helper extends Laravel5 {
    public function amSuperAdmin() {
        $this->amLoggedAs(['username' => 'super', 'password'=> 'password']);
    }
}

But this doesn't seem to work. When I use the declaration $this->amLoggedAs(['username' => 'super', 'password'=> 'password']); in a normal test it logs in the user as expected, but when I use $I->amSuperAdmin() it seems to fail to do so. There are no errors; the method is visible in my generated FunctionalTester class. When I trace the code I can see the authentication passing in the Laravel5::amLoggedAs method, but the test gets redirected to my app's login page as though authentication failed.

What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire