@@ -591,7 +591,9 @@ public function testSendNotificationEmailsIfRequired()
591591 ->get (MutableScopeConfigInterface::class);
592592 $ config ->setValue (
593593 'admin/emails/new_user_notification_template ' ,
594- $ this ->getCustomEmailTemplateIdForNewUserNotification ()
594+ $ this ->getCustomEmailTemplateId (
595+ 'admin_emails_new_user_notification_template '
596+ )
595597 );
596598 $ userModel = Bootstrap::getObjectManager ()
597599 ->create (User::class);
@@ -619,17 +621,17 @@ public function testSendNotificationEmailsIfRequired()
619621 }
620622
621623 /**
622- * Return email template id for new user notification
624+ * Return email template id by origin template code
623625 *
626+ * @param string $origTemplateCode
624627 * @return int|null
625628 * @throws NotFoundException
626629 */
627- private function getCustomEmailTemplateIdForNewUserNotification ( ): ?int
630+ private function getCustomEmailTemplateId ( string $ origTemplateCode ): ?int
628631 {
629632 $ templateId = null ;
630633 $ templateCollection = Bootstrap::getObjectManager ()
631- ->get (TemplateCollection::class);
632- $ origTemplateCode = 'admin_emails_new_user_notification_template ' ;
634+ ->create (TemplateCollection::class);
633635 foreach ($ templateCollection as $ template ) {
634636 if ($ template ->getOrigTemplateCode () == $ origTemplateCode ) {
635637 $ templateId = (int ) $ template ->getId ();
@@ -643,4 +645,33 @@ private function getCustomEmailTemplateIdForNewUserNotification(): ?int
643645 }
644646 return $ templateId ;
645647 }
648+
649+ /**
650+ * Verify custom notification is correctly when reset admin password
651+ *
652+ * @magentoDataFixture Magento/Email/Model/_files/email_template_reset_password_user_notification.php
653+ * @magentoDataFixture Magento/User/_files/user_with_role.php
654+ */
655+ public function testNotificationEmailsIfResetPassword ()
656+ {
657+ /** @var MutableScopeConfigInterface $config */
658+ $ config = Bootstrap::getObjectManager ()
659+ ->get (MutableScopeConfigInterface::class);
660+ $ config ->setValue (
661+ 'admin/emails/forgot_email_template ' ,
662+ $ this ->getCustomEmailTemplateId (
663+ 'admin_emails_forgot_email_template '
664+ )
665+ );
666+ $ userModel = $ this ->_model ->loadByUsername ('adminUser ' );
667+ $ notificator = $ this ->objectManager ->get (\Magento \User \Model \Spi \NotificatorInterface::class);
668+ $ notificator ->sendForgotPassword ($ userModel );
669+ /** @var TransportBuilderMock $transportBuilderMock */
670+ $ transportBuilderMock = $ this ->objectManager ->get (TransportBuilderMock::class);
671+ $ sentMessage = $ transportBuilderMock ->getSentMessage ();
672+ $ this ->assertStringContainsString (
673+ 'id= ' .$ userModel ->getId (),
674+ quoted_printable_decode ($ sentMessage ->getBodyText ())
675+ );
676+ }
646677}
0 commit comments