Blame view

frontend/tests/unit/models/ResetPasswordFormTest.php 1.42 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
  <?php
      
      namespace frontend\tests\unit\models;
      
      use common\fixtures\User as UserFixture;
      use frontend\models\ResetPasswordForm;
      
      class ResetPasswordFormTest extends \Codeception\Test\Unit
      {
          /**
           * @var \frontend\tests\UnitTester
           */
          protected $tester;
          
          public function _before()
          {
              $this->tester->haveFixtures(
                  [
                      'user' => [
                          'class'    => UserFixture::className(),
                          'dataFile' => codecept_data_dir() . 'user.php',
                      ],
                  ]
              );
          }
          
          public function testResetWrongToken()
          {
              $this->tester->expectException(
                  'yii\base\InvalidParamException',
                  function () {
                      new ResetPasswordForm('');
                  }
              );
              
              $this->tester->expectException(
                  'yii\base\InvalidParamException',
                  function () {
                      new ResetPasswordForm('notexistingtoken_1391882543');
                  }
              );
          }
          
          public function testResetCorrectToken()
          {
              $user = $this->tester->grabFixture('user', 0);
              $form = new ResetPasswordForm($user[ 'password_reset_token' ]);
              expect_that($form->resetPassword());
          }
          
      }