嗨,伙计们,我在编码方面有问题,
它无法正常工作,我正在使用所有相同的代码
有关于LaRabook
的视频从头开始这是我在 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());
这是我的注册控制器.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实例中,这对您毫无用处。
您必须依靠 Laravel5 模块并使用seeAuthentication()
来复制您的意图。