Php Larabook Auth::check()不工作
嗨,伙计们,我对codeception有个问题,Php Larabook Auth::check()不工作,php,laravel,Php,Laravel,嗨,伙计们,我对codeception有个问题, 它工作不正常,我使用的是相同的代码 有一些关于拉拉博OK的视频是从零开始的 这是我在signUpCept.php中的代码 $I = new FunctionalTester($scenario); $I->am('a guest'); $I->wantTo('Sign up for a Larabook account'); $I->amOnPage('/'); $I->click('Sign Up!'); $I->
它工作不正常,我使用的是相同的代码
有一些关于拉拉博OK的视频是从零开始的
这是我在signUpCept.php中的代码
$I = new FunctionalTester($scenario);
$I->am('a guest');
$I->wantTo('Sign up for a Larabook account');
$I->amOnPage('/');
$I->click('Sign Up!');
$I->seeCurrentUrlEquals('/register');
$I->fillField('Username:', 'JohnDoe');
$I->fillField('Email:', 'john@example.com');
$I->fillField('Password:', 'demo');
$I->fillField('Password Confirmation:', 'demo');
$I->click('Sign Up');
$I->seeCurrentUrlEquals('');
$I->see('Welcome to Larabook!');
$I->seeRecord('users',[
'username' => 'JohnDoe',
'email' => 'john@example.com',
'password' => 'demo'
]);
$I->assertTrue(Auth::check());
这是我的RegistrationController.php
class RegistrationController extends \BaseController {
/**
* Show a form to register the user.
*
* @return Response
*/
public function create()
{
return View::make('registration.create');
}
/**
* Creating a new Larbook user.
*
* @return Response
*/
public function store()
{
$user = User::create(
Input::only('username', 'email', 'password')
);
Auth::login($user);
return Redirect::home();
}
}
这就是我得到的错误
Functional Tests (1) ----------------------------------------------------------------------------------------
Sign up for a larabook account (SignUpCept) Fail
-------------------------------------------------------------------------------------------------------------
Time: 6.04 seconds, Memory: 25.50Mb
There was 1 failure:
---------
1) Failed to sign up for a larabook account in SignUpCept (tests/functional/SignUpCept.php)
Step I assert true false
Fail Failed asserting that false is true.
Scenario Steps:
13. $I->assertTrue(false) at tests/functional/SignUpCept.php:28
12. $I->seeRecord("users",{"username":"JohnDoe","email":"john@example.com","password":"demo"}) at tests/functional/SignUpCept.php:26
11. $I->see("Welcome to Larabook!") at tests/functional/SignUpCept.php:20
10. $I->seeCurrentUrlEquals("") at tests/functional/SignUpCept.php:19
9. $I->click("Sign Up") at tests/functional/SignUpCept.php:17
8. $I->fillField("Password Confirmation:","demo") at tests/functional/SignUpCept.php:15
FAILURES!
Tests: 1, Assertions: 4, Failures: 1.
您不能使用
Auth::check()
,请记住这里有两个实例,一个用于codeception,另一个用于正在测试的应用程序
这意味着您正试图Auth::check()
进入codeception实例,这对您来说是无用的
您必须依赖该模块,并使用
see authentication()
来复制您的意图。您是否发现了这一点?我也有同样的问题。