public function testChangePassword(FunctionalTester $I) { $I->amGoingTo('test the change password functionality'); // Create one user $user = Commons::createUser(); $I->amGoingTo('login a user'); $loginPage = LoginPage::openBy($I); $loginPage->login(Commons::TEST_EMAIL, Commons::TEST_PASSWORD); $changePasswordPage = ChangePasswordPage::openBy($I); $I->see('Change password'); $I->seeElement('#changepasswordform-newpassword'); $I->seeElement('#changepasswordform-newpasswordrepeat'); $I->dontSeeElement('#changepasswordform-email'); $I->dontSeeElement('#changepasswordform-oldpassword'); $I->amGoingTo('try to change the password with two different passwords for the new password and the new password repeat fields'); $changePasswordPage->changePassword('123123', '234234'); $I->expect('the form will catch the difference'); $I->see('The new passwords are not the same.'); $I->amGoingTo('test adding new password with length lower than the default length'); $changePasswordPage->changePassword('123', '123'); $I->expect('the form will warn the user'); $I->see('New password should contain at least 6 characters'); $I->see('New password repeat should contain at least 6 characters'); $I->amGoingTo('change the password of the user properly'); $changePasswordPage->changePassword('Nik)lay!23', 'Nik)lay!23'); $I->expect('that this time everything will be ok and the user will be redirected to the home page'); $user->refresh(); $I->assertNotNull($user->password_changed_at); $I->seeInCurrentUrl('/'); }
<?php use nkostadinov\user\tests\_pages\ChangePasswordPage; use nkostadinov\user\tests\_pages\LoginPage; use nkostadinov\user\tests\_pages\PasswordRecoveryRequestPage; use nkostadinov\user\tests\_pages\RegisterPage; $I = new FunctionalTester($scenario); $I->wantTo('test whether all view files are found by the controller actions'); // Login page test $loginPage = LoginPage::openBy($I); $I->seeInTitle('Login'); $I->seeElement('#login-form'); // Register page test RegisterPage::openBy($I); $I->seeInTitle('Signup'); // Change password page ChangePasswordPage::openBy($I); $I->seeInTitle('Change password'); $I->seeElement('#change-password-form'); // Password recovery page PasswordRecoveryRequestPage::openBy($I); $I->seeInTitle('Recover your password'); $I->seeElement('#password-recovery-form');