From 18c1223c7b3234296a8265af1372232ed71ea9eb Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 24 Dec 2014 22:52:14 +0100 Subject: [PATCH] Tests for the profile controller --- app/views/profile/change-password.blade.php | 2 +- tests/functional/ProfileControllerCest.php | 147 ++++++++++++++++++++ 2 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 tests/functional/ProfileControllerCest.php diff --git a/app/views/profile/change-password.blade.php b/app/views/profile/change-password.blade.php index ebc77df432..8cbcc0f8f9 100644 --- a/app/views/profile/change-password.blade.php +++ b/app/views/profile/change-password.blade.php @@ -8,7 +8,7 @@ Change your password
- {{Form::open(['class' => 'form-horizontal'])}} + {{Form::open(['class' => 'form-horizontal','id' => 'change-password'])}}
diff --git a/tests/functional/ProfileControllerCest.php b/tests/functional/ProfileControllerCest.php new file mode 100644 index 0000000000..fd7e1a53a6 --- /dev/null +++ b/tests/functional/ProfileControllerCest.php @@ -0,0 +1,147 @@ +amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']); + } + + /** + * @param FunctionalTester $I + */ + public function changePassword(FunctionalTester $I) + { + $I->wantTo('change my password.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + } + + /** + * @param FunctionalTester $I + */ + public function index(FunctionalTester $I) + { + $I->wantTo('see my profile options'); + $I->amOnPage('/profile'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Profile'); + } + + /** + * @param FunctionalTester $I + */ + public function postChangePassword(FunctionalTester $I) + { + $I->wantTo('submit a new password.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + $I->submitForm( + '#change-password', [ + 'old' => 'james', + 'new1' => 'James', + 'new2' => 'James' + ] + ); + $I->see('Password changed!'); + } + + /** + * @param FunctionalTester $I + */ + public function postChangePasswordInvalidCurrent(FunctionalTester $I) + { + $I->wantTo('submit a new password and enter the wrong current password.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + + $I->submitForm( + '#change-password', [ + 'old' => 'Blablabla', + 'new1' => 'James', + 'new2' => 'James' + ] + ); + $I->see('Invalid current password!'); + } + + /** + * @param FunctionalTester $I + */ + public function postChangePasswordNoNewPassword(FunctionalTester $I) + { + $I->wantTo('submit a new password and forget to fill in a new one.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + + $I->submitForm( + '#change-password', [ + 'old' => 'james', + 'new1' => '', + 'new2' => '' + ] + ); + $I->see('Do fill in a password!'); + + } + + /** + * @param FunctionalTester $I + */ + public function postChangePasswordToSame(FunctionalTester $I) + { + $I->wantTo('submit a new password but fill in my old one twice.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + + $I->submitForm( + '#change-password', [ + 'old' => 'james', + 'new1' => 'james', + 'new2' => 'james' + ] + ); + $I->see('The idea is to change your password.'); + } + + /** + * @param FunctionalTester $I + */ + public function postChangePasswordNoMatch(FunctionalTester $I) + { + $I->wantTo('submit a new password but make a mistake in filling it in twice.'); + $I->amOnPage('/profile/change-password'); + $I->see('thegrumpydictator@gmail.com'); + $I->see('Change your password'); + + $I->submitForm( + '#change-password', [ + 'old' => 'james', + 'new1' => 'blabla', + 'new2' => 'bla' + ] + ); + $I->see('New passwords do not match!'); + } + + +} \ No newline at end of file