-
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.
Fix for validation bug on password change
- Loading branch information
Andrey Gulitskiy
committed
Feb 15, 2014
1 parent
87f5b09
commit c4b118c
Showing
2 changed files
with
59 additions
and
1 deletion.
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,65 @@ public function testShouldChangePassword() | |
->andReturn( true ) | ||
->once(); | ||
|
||
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 call changePassword of the repository | ||
ConfideUser::$app['confide.repository'] = m::mock( 'ConfideRepository' ); | ||
ConfideUser::$app['confide.repository']->shouldReceive( 'changePassword' ) | ||
->never(); | ||
|
||
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 | ||
|