Skip to content

Firefly III: a personal finances manager

Tests for the profile controller

James Cole18c1223c7b32
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
</div>
<div class="panel-body">
- {{Form::open(['class' => 'form-horizontal'])}}
+ {{Form::open(['class' => 'form-horizontal','id' => 'change-password'])}}
<div class="form-group">
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
<div class="col-sm-8">
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 @@
+<?php
+
+/**
+ * Class ProfileControllerCest
+ */
+class ProfileControllerCest
+{
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function _after(FunctionalTester $I)
+ {
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function _before(FunctionalTester $I)
+ {
+ $I->amLoggedAs(['email' => '[email protected]', 'password' => 'james']);
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function changePassword(FunctionalTester $I)
+ {
+ $I->wantTo('change my password.');
+ $I->amOnPage('/profile/change-password');
+ $I->see('[email protected]');
+ $I->see('Change your password');
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function index(FunctionalTester $I)
+ {
+ $I->wantTo('see my profile options');
+ $I->amOnPage('/profile');
+ $I->see('[email protected]');
+ $I->see('Profile');
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function postChangePassword(FunctionalTester $I)
+ {
+ $I->wantTo('submit a new password.');
+ $I->amOnPage('/profile/change-password');
+ $I->see('[email protected]');
+ $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('[email protected]');
+ $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('[email protected]');
+ $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('[email protected]');
+ $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('[email protected]');
+ $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