for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: zjw
* Date: 2017/8/17
* Time: 下午5:04
*/
namespace zacksleo\yii2\backend\tests;
use yii\base\InvalidParamException;
use zacksleo\yii2\backend\models\Admin;
use zacksleo\yii2\backend\models\forms\ChangePasswordForm;
use yii;
class ChangePasswordFormTest extends TestCase
{
public function setUp()
parent::setUp();
$admin = Admin::findOne(1);
Yii::$app->user->setIdentity($admin);
}
public function testVerifyOldPassword()
$form = new ChangePasswordForm();
$form->old_password = "1!an1u0";
$form->new_password = "1ian1uo";
$form->new_password_repeat = "1ian1uo1";
$this->assertFalse($form->validate());
$form->new_password_repeat = "1ian1uo";
$this->assertTrue($form->validate());
$form->verifyOldPassword('old_password', []);
$form->validate();
$this->assertTrue(empty($form->getErrors()));
$form->old_password = "1ianlu0";
$this->assertFalse(empty($form->getErrors()));
public function testResetPassword()
$form->new_password = "lianluo";
$this->assertTrue($form->resetPassword());
$form->new_password = "1!an1u0";