@@ -37,15 +37,42 @@ public function testUpdatePassword()
3737
3838 $ this ->encoderFactory ->expects ($ this ->once ())
3939 ->method ('getEncoder ' )
40+ ->with ($ user )
4041 ->will ($ this ->returnValue ($ encoder ));
4142
4243 $ encoder ->expects ($ this ->once ())
4344 ->method ('encodePassword ' )
44- ->with ('password ' , $ user -> getSalt ( ))
45+ ->with ('password ' , $ this -> isType ( ' string ' ))
4546 ->will ($ this ->returnValue ('encodedPassword ' ));
4647
4748 $ this ->updater ->hashPassword ($ user );
4849 $ this ->assertSame ('encodedPassword ' , $ user ->getPassword (), '->updatePassword() sets encoded password ' );
50+ $ this ->assertNotNull ($ user ->getSalt ());
51+ $ this ->assertNull ($ user ->getPlainPassword (), '->updatePassword() erases credentials ' );
52+ }
53+
54+ public function testUpdatePasswordWithBCrypt ()
55+ {
56+ $ encoder = $ this ->getMockBuilder ('Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder ' )
57+ ->disableOriginalConstructor ()
58+ ->getMock ();
59+ $ user = new TestUser ();
60+ $ user ->setPlainPassword ('password ' );
61+ $ user ->setSalt ('old_salt ' );
62+
63+ $ this ->encoderFactory ->expects ($ this ->once ())
64+ ->method ('getEncoder ' )
65+ ->with ($ user )
66+ ->will ($ this ->returnValue ($ encoder ));
67+
68+ $ encoder ->expects ($ this ->once ())
69+ ->method ('encodePassword ' )
70+ ->with ('password ' , $ this ->isNull ())
71+ ->will ($ this ->returnValue ('encodedPassword ' ));
72+
73+ $ this ->updater ->hashPassword ($ user );
74+ $ this ->assertSame ('encodedPassword ' , $ user ->getPassword (), '->updatePassword() sets encoded password ' );
75+ $ this ->assertNull ($ user ->getSalt ());
4976 $ this ->assertNull ($ user ->getPlainPassword (), '->updatePassword() erases credentials ' );
5077 }
5178
0 commit comments