| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace frontend\tests\functional;
- use frontend\tests\FunctionalTester;
- class SignupCest
- {
- protected $formId = '#form-signup';
- public function _before(FunctionalTester $I)
- {
- $I->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('退出登录');
- }
- }
|