ResetPasswordFormTest.php 1.05 KB
Newer Older
1 2
<?php

3
namespace tests\codeception\frontend\unit\models;
4

5 6
use tests\codeception\frontend\unit\DbTestCase;
use tests\codeception\common\fixtures\UserFixture;
7 8 9 10 11
use frontend\models\ResetPasswordForm;

class ResetPasswordFormTest extends DbTestCase
{

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

    /**
21
     * @expectedException \yii\base\InvalidParamException
22 23 24 25 26
     */
    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' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php'
40 41 42
            ],
        ];
    }
43

44
}