Completed
Push — master ( 20b8ce...b87dd6 )
by Alexey
05:19
created

ResetPasswordFormTest::_before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace frontend\tests\unit\models;
4
5
use common\fixtures\User as UserFixture;
6
use modules\users\models\ResetPasswordForm;
7
8
/**
9
 * Class ResetPasswordFormTest
10
 * @package frontend\tests\unit\models
11
 */
12
class ResetPasswordFormTest extends \Codeception\Test\Unit
13
{
14
    /**
15
     * @var \frontend\tests\UnitTester
16
     */
17
    protected $tester;
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function _before()
23
    {
24
        $this->tester->haveFixtures([
25
            'user' => [
26
                'class' => UserFixture::className(),
27
                'dataFile' => codecept_data_dir() . 'user.php'
28
            ],
29
        ]);
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function testResetWrongToken()
36
    {
37
        $this->tester->expectException('yii\base\InvalidParamException', function() {
38
            new ResetPasswordForm('');
39
        });
40
41
        $this->tester->expectException('yii\base\InvalidParamException', function() {
42
            new ResetPasswordForm('notexistingtoken_1391882543');
43
        });
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function testResetCorrectToken()
50
    {
51
        $user = $this->tester->grabFixture('user', 2);
52
        $form = new ResetPasswordForm($user['password_reset_token']);
53
        expect_that($form->resetPassword());
54
    }
55
}
56