2016-02-27 03:52:09 +05:30
|
|
|
<?php
|
|
|
|
namespace tests\codeception\api\functional;
|
|
|
|
|
2016-02-27 04:07:29 +05:30
|
|
|
use common\models\Account;
|
2016-02-27 03:52:09 +05:30
|
|
|
use tests\codeception\api\_pages\AccountsRoute;
|
2016-05-11 01:55:04 +05:30
|
|
|
use tests\codeception\api\_pages\AuthenticationRoute;
|
2016-02-27 03:52:09 +05:30
|
|
|
use tests\codeception\api\FunctionalTester;
|
|
|
|
|
2016-02-27 04:07:29 +05:30
|
|
|
class AccountsChangePasswordCest {
|
2016-02-27 03:52:09 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* @var AccountsRoute
|
|
|
|
*/
|
|
|
|
private $route;
|
|
|
|
|
|
|
|
public function _before(FunctionalTester $I) {
|
|
|
|
$this->route = new AccountsRoute($I);
|
|
|
|
}
|
|
|
|
|
2016-05-10 17:37:32 +05:30
|
|
|
public function _after() {
|
2016-02-27 04:07:29 +05:30
|
|
|
/** @var Account $account */
|
|
|
|
$account = Account::findOne(1);
|
|
|
|
$account->setPassword('password_0');
|
|
|
|
$account->save();
|
|
|
|
}
|
|
|
|
|
2016-05-10 17:37:32 +05:30
|
|
|
public function testChangePassword(FunctionalTester $I) {
|
2016-02-27 03:52:09 +05:30
|
|
|
$I->wantTo('change my password');
|
2017-09-19 22:36:16 +05:30
|
|
|
$id = $I->amAuthenticated();
|
2016-02-27 03:52:09 +05:30
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
$this->route->changePassword($id, 'password_0', 'new-password', 'new-password');
|
2016-02-27 03:52:09 +05:30
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => true,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$I->notLoggedIn();
|
|
|
|
|
2016-05-11 01:55:04 +05:30
|
|
|
$loginRoute = new AuthenticationRoute($I);
|
2016-02-27 03:52:09 +05:30
|
|
|
$loginRoute->login('Admin', 'new-password');
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => true,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|