-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from Wyorma/bugfix
Fix for validation bug on password change. Thanks @Wyorma
- Loading branch information
Showing
2 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,13 +105,67 @@ public function testShouldChangePassword() | |
->andReturn( true ) | ||
->once(); | ||
|
||
// Should call validate method | ||
ConfideUser::$app['confide.repository']->shouldReceive('validate') | ||
->andReturn( true ) | ||
->once(); | ||
|
||
$this->populateUser(); | ||
|
||
$old_password = $this->confide_user->password; | ||
|
||
$this->assertTrue( $this->confide_user->resetPassword( $credentials ) ); | ||
} | ||
|
||
public function testShouldNotChangePassword() | ||
{ | ||
// Password should not be changed because it is empty | ||
$credentials = array( | ||
'email'=>'[email protected]', | ||
'password'=>'', | ||
'password_confirmation'=>'' | ||
); | ||
|
||
// Should not call changePassword of the repository | ||
ConfideUser::$app['confide.repository'] = m::mock( 'ConfideRepository' ); | ||
ConfideUser::$app['confide.repository']->shouldReceive( 'changePassword' ) | ||
->never(); | ||
|
||
// Should call validate method | ||
ConfideUser::$app['confide.repository']->shouldReceive('validate') | ||
->andReturn( false ) | ||
->times(4); | ||
|
||
$this->populateUser(); | ||
|
||
$this->assertFalse( $this->confide_user->resetPassword( $credentials ) ); | ||
|
||
// Additional asserts | ||
// Password should not be changed because it is too short | ||
$credentials = array( | ||
'email'=>'[email protected]', | ||
'password'=>'39a', | ||
'password_confirmation'=>'39a' | ||
); | ||
$this->assertFalse( $this->confide_user->resetPassword( $credentials ) ); | ||
|
||
// Password should not be changed because it is too long | ||
$credentials = array( | ||
'email'=>'[email protected]', | ||
'password'=>'1a2f34g5uj887n', | ||
'password_confirmation'=>'1a2f34g5uj887n' | ||
); | ||
$this->assertFalse( $this->confide_user->resetPassword( $credentials ) ); | ||
|
||
// Password should not be changed because it is not confirmed | ||
$credentials = array( | ||
'email'=>'[email protected]', | ||
'password'=>'987987', | ||
'password_confirmation'=>'562906' | ||
); | ||
$this->assertFalse( $this->confide_user->resetPassword( $credentials ) ); | ||
} | ||
|
||
public function testShouldNotSaveDuplicated() | ||
{ | ||
// Make sure that userExists return 1 to simulates a duplicated user | ||
|