@@ -591,7 +591,9 @@ public function testSendNotificationEmailsIfRequired()
591
591
->get (MutableScopeConfigInterface::class);
592
592
$ config ->setValue (
593
593
'admin/emails/new_user_notification_template ' ,
594
- $ this ->getCustomEmailTemplateIdForNewUserNotification ()
594
+ $ this ->getCustomEmailTemplateIdForNewUserNotification (
595
+ 'admin_emails_new_user_notification_template '
596
+ )
595
597
);
596
598
$ userModel = Bootstrap::getObjectManager ()
597
599
->create (User::class);
@@ -621,15 +623,15 @@ public function testSendNotificationEmailsIfRequired()
621
623
/**
622
624
* Return email template id for new user notification
623
625
*
626
+ * @param string $origTemplateCode
624
627
* @return int|null
625
628
* @throws NotFoundException
626
629
*/
627
- private function getCustomEmailTemplateIdForNewUserNotification (): ?int
630
+ private function getCustomEmailTemplateIdForNewUserNotification (string $ origTemplateCode ): ?int
628
631
{
629
632
$ templateId = null ;
630
633
$ templateCollection = Bootstrap::getObjectManager ()
631
634
->get (TemplateCollection::class);
632
- $ origTemplateCode = 'admin_emails_new_user_notification_template ' ;
633
635
foreach ($ templateCollection as $ template ) {
634
636
if ($ template ->getOrigTemplateCode () == $ origTemplateCode ) {
635
637
$ templateId = (int ) $ template ->getId ();
@@ -643,4 +645,33 @@ private function getCustomEmailTemplateIdForNewUserNotification(): ?int
643
645
}
644
646
return $ templateId ;
645
647
}
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 ->getCustomEmailTemplateIdForNewUserNotification (
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
+ }
646
677
}
0 commit comments