You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
7 years ago
|
<?php
|
||
|
|
||
|
namespace frontend\tests\unit\models;
|
||
|
|
||
|
use common\fixtures\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());
|
||
|
}
|
||
|
|
||
|
}
|