@@ -41,20 +41,38 @@ public function setUp()
4141 }
4242
4343 /**
44- * Test that the handle function does not attempt to hash a password if no password is passed.
44+ * Test that the handle function does not attempt to hash a password if no
45+ * password is provided or the password is null.
46+ *
47+ * @dataProvider badPasswordDataProvider
4548 */
46- public function testUpdateUserWithoutTouchingHasherIfNoPasswordPassed ()
49+ public function testUpdateUserWithoutTouchingHasherIfNoPasswordPassed (array $ data )
4750 {
4851 $ user = factory (User::class)->make ();
4952 $ this ->revocationService ->shouldReceive ('getExceptions ' )->withNoArgs ()->once ()->andReturn ([]);
5053 $ this ->repository ->shouldReceive ('update ' )->with ($ user ->id , ['test-data ' => 'value ' ])->once ()->andReturnNull ();
5154
52- $ response = $ this ->getService ()->handle ($ user , [ ' test- data' => ' value ' ] );
55+ $ response = $ this ->getService ()->handle ($ user , $ data );
5356 $ this ->assertInstanceOf (Collection::class, $ response );
5457 $ this ->assertTrue ($ response ->has ('model ' ));
5558 $ this ->assertTrue ($ response ->has ('exceptions ' ));
5659 }
5760
61+ /**
62+ * Provide a test data set with passwords that should not be hashed.
63+ *
64+ * @return array
65+ */
66+ public function badPasswordDataProvider (): array
67+ {
68+ return [
69+ [['test-data ' => 'value ' ]],
70+ [['test-data ' => 'value ' , 'password ' => null ]],
71+ [['test-data ' => 'value ' , 'password ' => '' ]],
72+ [['test-data ' => 'value ' , 'password ' => 0 ]],
73+ ];
74+ }
75+
5876 /**
5977 * Test that the handle function hashes a password if passed in the data array.
6078 */
0 commit comments