我正在尝试使用协同欺骗来测试laravel应用程序。在Laravel内部,我使用Sentinel进行身份验证。我在内部测试中验证用户时遇到问题。
以下示例均不起作用:
$I->authenticateTestUser($I);
$user = \App\User::where('email','=','test@test.com')->first();
$I->amLoggedAs($user);
$I->canSeeAuthentication();
$credentials = [
'email' => 'test@test.com',
'password' => '****',
];
Sentinel::authenticate($credentials, true);
$I->canSeeAuthentication();
$I->amOnPage('/login');
$I->fillField('email', $email);
$I->fillField('password', $password);
$I->click('Login');
$I->canSeeAuthentication();如何在协同欺骗功能测试中进行身份验证?
发布于 2016-03-08 02:01:55
您只需在_before方法中使用sentinel:
private $_user;
private $_credentials;
public function _before(FunctionalTester $I)
{
// we create a user
$this->_credentials = [
'last_name' => 'Test',
'first_name' => 'test',
'email' => 'test@test.fr',
'password' => 'password',
];
$this->_user = \Sentinel::register($this->_credentials, true);
// we log this user
\Sentinel::authenticate($this->_credentials);
}您将能够在测试中重用您的用户或凭据。
https://stackoverflow.com/questions/35164185
复制相似问题