public function create(WebGuy $I, $id) { $I->haveInDatabase('bolt_users', array('id' => $id, 'username' => $this->username, 'password' => $this->getHashedPassword(), 'email' => $this->username . '@example.org', 'lastseen' => '1900-01-01', 'lastip' => '', 'displayname' => ucwords($this->username), 'stack' => serialize(array()), 'enabled' => '1', 'shadowpassword' => '', 'shadowtoken' => '', 'shadowvalidity' => '1900-01-01', 'failedlogins' => '0', 'throttleduntil' => '1900-01-01', 'roles' => json_encode($this->roles))); }
* * @author Brett O'Donnell <*****@*****.**> * @author Zain Ul abidin <*****@*****.**> * @copyright 2013 Mr PHP * @link https://github.com/cornernote/yii-account-module * @license BSD-3-Clause https://raw.github.com/cornernote/yii-account-module/master/LICENSE * * @package yii-account-module */ $I = new WebGuy($scenario); $I->wantTo('ensure AccountAccountController activate works'); // check we are not logged in $I->amOnPage('/'); $I->see('Hello guest'); // add user to the database $I->haveInDatabase('account_user', array('username' => 'demo-activate', 'password' => '$2a$13$.m7wlozeIJuRtKp01lR4peYybArVLdO6Pf1JsPSnX6eISL9GXDWBu', 'first_name' => 'demo-activate', 'last_name' => 'demo-activate', 'email' => '*****@*****.**', 'activated' => 0)); // add a token to the database $I->haveInDatabase('token', array('token' => '$2a$13$lRkdb6kwbIC9aGTkdei2h.NQNlZht9Bpdo2J0PqsJ3tHAFsYJNg7C', 'model_name' => 'AccountActivate', 'model_id' => 2, 'uses_allowed' => 1, 'uses_remaining' => 1, 'expires' => strtotime('+1day'), 'created' => time())); // check with invalid token $I->amOnPage('/account/account/activate/user_id/2/token/test-invalid-token'); $I->see('Invalid token.'); // reset password with empty details $I->amOnPage('/account/account/activate/user_id/2/token/test-token'); $I->see('Your account has been activated and you have been logged in.'); // check login $I->amOnPage('/'); $I->see('Hello demo-activate'); // logout $I->amOnPage('/account/account/logout'); $I->see('Your have been logged out.'); // ensure token is expired
* * @author Brett O'Donnell <*****@*****.**> * @author Zain Ul abidin <*****@*****.**> * @copyright 2013 Mr PHP * @link https://github.com/cornernote/yii-account-module * @license BSD-3-Clause https://raw.github.com/cornernote/yii-account-module/master/LICENSE * * @package yii-account-module */ $I = new WebGuy($scenario); $I->wantTo('ensure AccountAccountController reset password works'); // check we are not logged in $I->amOnPage('/'); $I->see('Hello guest'); // add a token to the database $I->haveInDatabase('token', array('token' => '$2a$13$lRkdb6kwbIC9aGTkdei2h.NQNlZht9Bpdo2J0PqsJ3tHAFsYJNg7C', 'model_name' => 'AccountLostPassword', 'model_id' => 1, 'uses_allowed' => 1, 'uses_remaining' => 1, 'expires' => strtotime('+1day'), 'created' => time())); // check with invalid token $I->amOnPage('/account/account/resetPassword/user_id/1/token/test-invalid-token'); $I->see('Invalid token.'); // reset password with empty details $I->amOnPage('/account/account/resetPassword/user_id/1/token/test-token'); $I->fillField('AccountResetPassword_new_password', ''); $I->fillField('AccountResetPassword_confirm_password', ''); $I->click('Save Password'); $I->see('Please fix the following input errors:'); $I->see('New Password cannot be blank.'); $I->see('Confirm Password cannot be blank.'); // reset password with password mismatch $I->amOnPage('/account/account/resetPassword/user_id/1/token/test-token'); $I->fillField('AccountResetPassword_new_password', 'admin123'); $I->fillField('AccountResetPassword_confirm_password', 'admin321');