new-support.webeffector.ru/frontend/tests/unit/models/ResetPasswordFormTest.php

45 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2024-06-13 17:07:58 +03:00
<?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::class,
'dataFile' => codecept_data_dir() . 'user.php'
],
]);
}
public function testResetWrongToken()
{
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
new ResetPasswordForm('');
});
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
new ResetPasswordForm('notexistingtoken_1391882543');
});
}
public function testResetCorrectToken()
{
$user = $this->tester->grabFixture('user', 0);
$form = new ResetPasswordForm($user['password_reset_token']);
verify($form->resetPassword())->notEmpty();
}
}