Blame view

frontend/tests/functional/LoginCest.php 1.34 KB
1755c393   Yarik   Basic template in...
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
  <?php
  
  namespace frontend\tests\functional;
  
  use frontend\tests\FunctionalTester;
  use common\fixtures\User as UserFixture;
  
  class LoginCest
  {
      function _before(FunctionalTester $I)
      {
          $I->haveFixtures([
              'user' => [
                  'class' => UserFixture::className(),
                  'dataFile' => codecept_data_dir() . 'login_data.php'
              ]
          ]);
          $I->amOnRoute('site/login');
      }
  
      protected function formParams($login, $password)
      {
          return [
              'LoginForm[username]' => $login,
              'LoginForm[password]' => $password,
          ];
      }
  
      public function checkEmpty(FunctionalTester $I)
      {
          $I->submitForm('#login-form', $this->formParams('', ''));
          $I->seeValidationError('Username cannot be blank.');
          $I->seeValidationError('Password cannot be blank.');
      }
  
      public function checkWrongPassword(FunctionalTester $I)
      {
          $I->submitForm('#login-form', $this->formParams('admin', 'wrong'));
          $I->seeValidationError('Incorrect username or password.');
      }
      
      public function checkValidLogin(FunctionalTester $I)
      {
          $I->submitForm('#login-form', $this->formParams('erau', 'password_0'));
          $I->see('Logout (erau)', 'form button[type=submit]');
          $I->dontSeeLink('Login');
          $I->dontSeeLink('Signup');
      }
  }