ResetPasswordFormTest.php 1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<?php

namespace frontend\tests\unit\models;

use frontend\tests\unit\DbTestCase;
use common\tests\fixtures\UserFixture;
use frontend\models\ResetPasswordForm;

class ResetPasswordFormTest extends DbTestCase
{

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    /**
     * @expectedException yii\base\InvalidParamException
     */
    public function testResetWrongToken()
    {
        new ResetPasswordForm('notexistingtoken_1391882543');
    }

    /**
     * @expectedException yii\base\InvalidParamException
     */
    public function testResetEmptyToken()
    {
        new ResetPasswordForm('');
    }
27

28
    public function testResetCorrectToken()
29
    {
30 31
        $form = new ResetPasswordForm($this->user[0]['password_reset_token']);
        expect('password should be resetted', $form->resetPassword())->true();
32
    }
33

34 35 36 37 38
    public function fixtures()
    {
        return [
            'user' => [
                'class' => UserFixture::className(),
39
                'dataFile' => '@frontend/tests/unit/fixtures/data/models/user.php'
40 41 42
            ],
        ];
    }
43

44
}