Blame view

frontend/tests/functional/SignupCest.php 2.02 KB
950817c6   Alex Savenko   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  <?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('Signup', 'h1');
              $I->see('Please fill out the following fields to signup:');
              $I->submitForm($this->formId, []);
              $I->seeValidationError('Username cannot be blank.');
              $I->seeValidationError('Email cannot be blank.');
              $I->seeValidationError('Password cannot be blank.');
              
          }
          
          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('Email is not a valid email address.', '.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('Logout (tester)', 'form button[type=submit]');
          }
      }