【发布时间】:2016-03-08 02:01:54
【问题描述】:
我正在尝试使用 codeception 测试 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();
如何在代码接收功能测试中进行身份验证?
【问题讨论】:
-
不能使用
Sentinel::authenticate,codeception实例与application不一样。
标签: laravel codeception