@@ -199,7 +199,7 @@ public function iShouldNotReceiveAnyEmails()
199199 }
200200
201201 /**
202- * @Then /^I should get a(?:n|) "(.+ )" email sent(?:| to the email address "(.+ )")$/i
202+ * @Then /^I should get a(?:n|) "([^" ]* )" email sent(?:| to the email address "([^" ]* )")$/i
203203 */
204204 public function iShouldGetAnEmail (string $ emailType , string $ emailAddress = 'user@example.com ' )
205205 {
@@ -242,7 +242,7 @@ public function iShouldGetAnEmail(string $emailType, string $emailAddress = 'use
242242 $ this ->validateChangeEmailVerification ($ context , $ headers , true );
243243 break ;
244244 case 'change_email_confirmation ' :
245- $ this ->validateChangeEmailVerification ($ context , $ headers );
245+ $ this ->validateChangeEmailVerification ($ context , $ headers, false , $ context [ ' user ' ]-> getUsername () );
246246 break ;
247247 case 'change_password_notification ' :
248248 $ this ->validateChangePasswordNotification ($ headers );
@@ -283,13 +283,16 @@ private function validateEnabledNotification(Headers $headers): void
283283 Assert::assertStringStartsWith (UserEnabledEmailFactory::MESSAGE_ID_PREFIX , $ headers ->get ('x-message-id ' )->getBodyAsString ());
284284 }
285285
286- private function validateChangeEmailVerification (array $ context , Headers $ headers , bool $ customPath = false ): void
286+ private function validateChangeEmailVerification (array $ context , Headers $ headers , bool $ customPath = false , ? string $ username = null ): void
287287 {
288+ if (!$ username ) {
289+ $ username = 'new_user ' ;
290+ }
288291 $ pathInsert = $ customPath ? 'another-path ' : 'confirm-new-email ' ;
289292 Assert::assertEquals ('Please confirm your new email address ' , $ headers ->get ('subject ' )->getBodyAsString ());
290293 Assert::assertStringStartsWith (ChangeEmailConfirmationEmailFactory::MESSAGE_ID_PREFIX , $ headers ->get ('x-message-id ' )->getBodyAsString ());
291294 Assert::assertIsString ($ context ['user ' ]->getNewEmailConfirmationToken ());
292- Assert::assertMatchesRegularExpression ('/^http:\/\/www.website.com\/ ' . $ pathInsert . '\/new_user \/new%40example.com\/([a-z0-9]+)$/i ' , $ context ['redirect_url ' ]);
295+ Assert::assertMatchesRegularExpression ('/^http:\/\/www\ .website\ .com\/ ' . $ pathInsert . '\/ ' . $ username . ' \/new%40example.com\/([a-z0-9]+)$/i ' , $ context ['redirect_url ' ]);
293296 }
294297
295298 private function validateChangePasswordNotification (Headers $ headers ): void
0 commit comments