@@ -155,8 +155,7 @@ public function testLimitNumberOfResetRequestPerHourByEmail(): void
155
155
$ this ->reinitableConfig ->reinit ();
156
156
157
157
// Resetting Password
158
- $ this ->getRequest ()->setPostValue ('email ' , $ adminEmail );
159
- $ this ->dispatch ('backend/admin/auth/forgotpassword ' );
158
+ $ this ->resetPassword ($ adminEmail );
160
159
161
160
/** @var TransportBuilderMock $transportMock */
162
161
$ transportMock = Bootstrap::getObjectManager ()->get (
@@ -183,19 +182,15 @@ public function testLimitNumberOfResetRequestPerHourByEmail(): void
183
182
);
184
183
$ this ->reinitableConfig ->reinit ();
185
184
186
- $ this ->getRequest ()->setPostValue ('email ' , $ adminEmail );
187
- $ this ->dispatch ('backend/admin/auth/forgotpassword ' );
188
-
185
+ $ this ->resetPassword ($ adminEmail );
189
186
$ this ->assertSessionMessages (
190
187
$ this ->equalTo ([]),
191
188
MessageInterface::TYPE_ERROR
192
189
);
193
190
194
191
// Resetting password multiple times
195
192
for ($ i = 0 ; $ i < 2 ; $ i ++) {
196
- $ this ->getRequest ()->setPostValue ('email ' , $ adminEmail );
197
- $ this ->dispatch ('backend/admin/auth/forgotpassword ' );
198
-
193
+ $ this ->resetPassword ($ adminEmail );
199
194
$ this ->assertSessionMessages (
200
195
$ this ->equalTo (
201
196
['We received too many requests for password resets. '
@@ -212,13 +207,21 @@ public function testLimitNumberOfResetRequestPerHourByEmail(): void
212
207
213
208
$ this ->assertEquals (0 , $ connection ->fetchOne ("SELECT COUNT(*) FROM $ tableName " ));
214
209
215
- $ this ->getRequest ()->setPostValue ('email ' , $ adminEmail );
216
- $ this ->dispatch ('backend/admin/auth/forgotpassword ' );
217
-
210
+ $ this ->resetPassword ($ adminEmail );
218
211
$ sendMessage = $ transportMock ->getSentMessage ()->getBody ()->getParts ()[0 ]->getRawContent ();
219
212
$ this ->assertStringContainsString (
220
213
'There was recently a request to change the password for your account ' ,
221
214
$ sendMessage
222
215
);
223
216
}
217
+
218
+ /**
219
+ * @param $adminEmail
220
+ * @return void
221
+ */
222
+ private function resetPassword ($ adminEmail ): void
223
+ {
224
+ $ this ->getRequest ()->setPostValue ('email ' , $ adminEmail );
225
+ $ this ->dispatch ('backend/admin/auth/forgotpassword ' );
226
+ }
224
227
}
0 commit comments