Skip to content

Commit e923cb3

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-39757' into 2.4-develop-pr51
2 parents eb55d76 + e365e02 commit e923cb3

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<!--@subject {{trans "Password Reset Confirmation for %name" name=$username}} @-->
88
<!--@vars {
99
"var store.frontend_name":"Store Name",
10-
"var user.id":"Account Holder Id",
10+
"var user.user_id":"Account Holder Id",
1111
"var user.rp_token":"Reset Password Token",
1212
"var user.name":"Account Holder Name",
13-
"store url=\"admin\/auth\/resetpassword\/\" _query_id=$user.id _query_token=$user.rp_token":"Reset Password URL",
13+
"store url=\"admin\/auth\/resetpassword\/\" _query_id=$user.user_id _query_token=$user.rp_token":"Reset Password URL",
1414
"var username":"Account Holder Name"
1515
} @-->
1616

@@ -20,7 +20,7 @@
2020

2121
{{trans "If you requested this change, reset your password here:"}}
2222

23-
{{store url="admin/auth/resetpassword/" _query_id=$user.id _query_token=$user.rp_token _nosid=1}}
23+
{{store url="admin/auth/resetpassword/" _query_id=$user.user_id _query_token=$user.rp_token _nosid=1}}
2424

2525
{{trans "If you did not make this request, you can ignore this email and your password will remain the same."}}
2626

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
$origTemplateCode = 'admin_emails_forgot_email_template';
9+
/** @var \Magento\Email\Model\Template $template */
10+
$template = $objectManager->create(\Magento\Email\Model\Template::class);
11+
$template->loadDefault($origTemplateCode);
12+
$template->setTemplateCode('Reset Password User Notification Custom Code');
13+
$template->setOrigTemplateCode('admin_emails_forgot_email_template');
14+
$template->setId(null);
15+
$template->save();

dev/tests/integration/testsuite/Magento/User/Model/UserTest.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)