File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1139,6 +1139,44 @@ public function seeCurrentActionIs($action)
1139
1139
$ this ->fail ("Action ' $ action' does not exist " );
1140
1140
}
1141
1141
1142
+ /**
1143
+ * Checks that the user's password would not benefit from rehashing.
1144
+ * If the user is not provided it is taken from the current session.
1145
+ *
1146
+ * You might use this function after performing tasks like registering a user or submitting a password update form.
1147
+ *
1148
+ * ```php
1149
+ * <?php
1150
+ * $I->seeUserPasswordDoesNotNeedRehash();
1151
+ * $I->seeUserPasswordDoesNotNeedRehash($user);
1152
+ * ```
1153
+ *
1154
+ * @param UserInterface|null $user
1155
+ */
1156
+ public function seeUserPasswordDoesNotNeedRehash (UserInterface $ user = null )
1157
+ {
1158
+ $ container = $ this ->_getContainer ();
1159
+
1160
+ if (!$ user ) {
1161
+ if (!$ container ->has ('security.helper ' )) {
1162
+ $ this ->fail ("Symfony container doesn't have 'security.helper' service " );
1163
+ }
1164
+
1165
+ $ security = $ this ->grabService ('security.helper ' );
1166
+ if (!$ user = $ security ->getUser ()) {
1167
+ $ this ->fail ('No user found to validate ' );
1168
+ }
1169
+ }
1170
+
1171
+ if (!$ container ->has ('security.user_password_encoder.generic ' )) {
1172
+ $ this ->fail ("Symfony container doesn't have 'security.user_password_encoder.generic' service " );
1173
+ }
1174
+
1175
+ $ encoder = $ this ->grabService ('security.user_password_encoder.generic ' );
1176
+
1177
+ $ this ->assertFalse ($ encoder ->needsRehash ($ user ), 'User password needs rehash ' );
1178
+ }
1179
+
1142
1180
public function amLoggedInAs (UserInterface $ user , $ firewallName = 'main ' , $ firewallContext = null )
1143
1181
{
1144
1182
$ container = $ this ->_getContainer ();
You can’t perform that action at this time.
0 commit comments