amOnRoute('site/signup'); } public function signupWithEmptyFields(FunctionalTester $I) { $I->see('注册', 'h1'); $I->submitForm($this->formId, []); $I->seeValidationError('用户名不能为空'); $I->seeValidationError('邮箱不能为空'); $I->seeValidationError('密码不能为空'); } public function signupWithWrongEmail(FunctionalTester $I) { $I->submitForm( $this->formId, [ 'SignupForm[username]' => 'tester', 'SignupForm[email]' => 'ttttt', 'SignupForm[password]' => 'tester_password', ] ); $I->dontSee('Username cannot be blank.', '.help-block'); $I->dontSee('Password cannot be blank.', '.help-block'); $I->see('邮箱不是有效的邮箱地址。', '.help-block'); } public function signupSuccessfully(FunctionalTester $I) { $I->submitForm($this->formId, [ 'SignupForm[username]' => 'tester', 'SignupForm[email]' => 'tester.email@example.com', 'SignupForm[password]' => 'tester_password', ]); $I->seeRecord('common\models\User', [ 'username' => 'tester', 'email' => 'tester.email@example.com', ]); $I->see('退出登录'); } }