Skip to content

Commit e85ef38

Browse files
ENGCOM-7500: MC-33148: A link to resend a confirmation email is not clickable #27662
- Merge Pull Request #27662 from VladimirZaets/magento2:MC-33203 - Merged commits: 1. cbcf369 2. 1efab36 3. 1e66741 4. 233a81a 5. dd26c37 6. f57c14b 7. f58b8a0 8. a2d0302 9. 251c1bb 10. 5fd9cc2 11. 91cd697 12. a413b74 13. ab6d6c5
2 parents 9df4250 + ab6d6c5 commit e85ef38

File tree

9 files changed

+84
-47
lines changed

9 files changed

+84
-47
lines changed

app/code/Magento/Catalog/Helper/Output.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function productAttribute($product, $attributeHtml, $attributeName)
182182
if ($attributeHtml !== null
183183
&& $attribute->getIsHtmlAllowedOnFront()
184184
&& $attribute->getIsWysiwygEnabled()
185-
&& $this->isDirectivesExists($attributeHtml)
185+
&& $this->isDirectivesExists((string)$attributeHtml)
186186
) {
187187
$attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml);
188188
}
@@ -219,7 +219,7 @@ public function categoryAttribute($category, $attributeHtml, $attributeName)
219219
if ($attributeHtml !== null
220220
&& $attribute->getIsHtmlAllowedOnFront()
221221
&& $attribute->getIsWysiwygEnabled()
222-
&& $this->isDirectivesExists($attributeHtml)
222+
&& $this->isDirectivesExists((string)$attributeHtml)
223223

224224
) {
225225
$attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml);
@@ -238,7 +238,7 @@ public function categoryAttribute($category, $attributeHtml, $attributeName)
238238
* @param string $attributeHtml
239239
* @return bool
240240
*/
241-
public function isDirectivesExists($attributeHtml)
241+
public function isDirectivesExists(string $attributeHtml): bool
242242
{
243243
$matches = false;
244244
foreach ($this->directivePatterns as $pattern) {

app/code/Magento/Customer/Controller/Account/Confirm.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
/**
2525
* Class Confirm
2626
*
27+
* Confirm class is responsible for account confirmation flow
28+
*
2729
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2830
*/
2931
class Confirm extends AbstractAccount implements HttpGetActionInterface
@@ -168,7 +170,7 @@ public function execute()
168170
$metadata->setPath('/');
169171
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
170172
}
171-
$this->messageManager->addSuccessMessage($this->getSuccessMessage());
173+
$this->messageManager->addSuccess($this->getSuccessMessage());
172174
$resultRedirect->setUrl($this->getSuccessRedirect());
173175
return $resultRedirect;
174176
} catch (StateException $e) {

app/code/Magento/Customer/Controller/Account/LoginPost.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class LoginPost extends AbstractAccount implements CsrfAwareActionInterface, Htt
6767
*/
6868
private $cookieMetadataManager;
6969

70+
/**
71+
* @var CustomerUrl
72+
*/
73+
private $customerUrl;
74+
7075
/**
7176
* @param Context $context
7277
* @param Session $customerSession
@@ -199,11 +204,11 @@ public function execute()
199204
return $resultRedirect;
200205
}
201206
} catch (EmailNotConfirmedException $e) {
202-
$value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
203-
$message = __(
204-
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
205-
$value
207+
$this->messageManager->addComplexErrorMessage(
208+
'confirmAccountErrorMessage',
209+
['url' => $this->customerUrl->getEmailConfirmationUrl($login['username'])]
206210
);
211+
$this->session->setUsername($login['username']);
207212
} catch (AuthenticationException $e) {
208213
$message = __(
209214
'The account sign-in was incorrect or your account is disabled temporarily. '

app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,77 +23,77 @@ class ConfirmTest extends \PHPUnit\Framework\TestCase
2323
protected $model;
2424

2525
/**
26-
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
26+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit\Framework\MockObject\MockObject
2727
*/
2828
protected $requestMock;
2929

3030
/**
31-
* @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
31+
* @var \Magento\Framework\App\ResponseInterface|\PHPUnit\Framework\MockObject\MockObject
3232
*/
3333
protected $responseMock;
3434

3535
/**
36-
* @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
36+
* @var \Magento\Customer\Model\Session|\PHPUnit\Framework\MockObject\MockObject
3737
*/
3838
protected $customerSessionMock;
3939

4040
/**
41-
* @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject
41+
* @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit\Framework\MockObject\MockObject
4242
*/
4343
protected $redirectMock;
4444

4545
/**
46-
* @var \Magento\Framework\Url|\PHPUnit_Framework_MockObject_MockObject
46+
* @var \Magento\Framework\Url|\PHPUnit\Framework\MockObject\MockObject
4747
*/
4848
protected $urlMock;
4949

5050
/**
51-
* @var \Magento\Customer\Api\AccountManagementInterface|\PHPUnit_Framework_MockObject_MockObject
51+
* @var \Magento\Customer\Api\AccountManagementInterface|\PHPUnit\Framework\MockObject\MockObject
5252
*/
5353
protected $customerAccountManagementMock;
5454

5555
/**
56-
* @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
56+
* @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject
5757
*/
5858
protected $customerRepositoryMock;
5959

6060
/**
61-
* @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject
61+
* @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit\Framework\MockObject\MockObject
6262
*/
6363
protected $customerDataMock;
6464

6565
/**
66-
* @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
66+
* @var \Magento\Framework\Message\ManagerInterface|\PHPUnit\Framework\MockObject\MockObject
6767
*/
6868
protected $messageManagerMock;
6969

7070
/**
71-
* @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject
71+
* @var \Magento\Customer\Helper\Address|\PHPUnit\Framework\MockObject\MockObject
7272
*/
7373
protected $addressHelperMock;
7474

7575
/**
76-
* @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject
76+
* @var \Magento\Store\Model\StoreManager|\PHPUnit\Framework\MockObject\MockObject
7777
*/
7878
protected $storeManagerMock;
7979

8080
/**
81-
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
81+
* @var \Magento\Store\Model\Store|\PHPUnit\Framework\MockObject\MockObject
8282
*/
8383
protected $storeMock;
8484

8585
/**
86-
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
86+
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit\Framework\MockObject\MockObject
8787
*/
8888
protected $scopeConfigMock;
8989

9090
/**
91-
* @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
91+
* @var \Magento\Framework\App\Action\Context|\PHPUnit\Framework\MockObject\MockObject
9292
*/
9393
protected $contextMock;
9494

9595
/**
96-
* @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject
96+
* @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit\Framework\MockObject\MockObject
9797
*/
9898
protected $redirectResultMock;
9999

@@ -282,7 +282,7 @@ public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $ad
282282
->willReturnSelf();
283283

284284
$this->messageManagerMock->expects($this->any())
285-
->method('addSuccessMessage')
285+
->method('addSuccess')
286286
->with($this->stringContains($successMessage))
287287
->willReturnSelf();
288288

@@ -402,7 +402,7 @@ public function testSuccessRedirect(
402402
->willReturnSelf();
403403

404404
$this->messageManagerMock->expects($this->any())
405-
->method('addSuccessMessage')
405+
->method('addSuccess')
406406
->with($this->stringContains($successMessage))
407407
->willReturnSelf();
408408

app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,62 +28,62 @@ class LoginPostTest extends \PHPUnit\Framework\TestCase
2828
protected $controller;
2929

3030
/**
31-
* @var Context | \PHPUnit_Framework_MockObject_MockObject
31+
* @var Context | \PHPUnit\Framework\MockObject\MockObject
3232
*/
3333
protected $context;
3434

3535
/**
36-
* @var Session | \PHPUnit_Framework_MockObject_MockObject
36+
* @var Session | \PHPUnit\Framework\MockObject\MockObject
3737
*/
3838
protected $session;
3939

4040
/**
41-
* @var AccountManagementInterface | \PHPUnit_Framework_MockObject_MockObject
41+
* @var AccountManagementInterface | \PHPUnit\Framework\MockObject\MockObject
4242
*/
4343
protected $accountManagement;
4444

4545
/**
46-
* @var Url | \PHPUnit_Framework_MockObject_MockObject
46+
* @var Url | \PHPUnit\Framework\MockObject\MockObject
4747
*/
4848
protected $url;
4949

5050
/**
51-
* @var \Magento\Framework\Data\Form\FormKey\Validator | \PHPUnit_Framework_MockObject_MockObject
51+
* @var \Magento\Framework\Data\Form\FormKey\Validator | \PHPUnit\Framework\MockObject\MockObject
5252
*/
5353
protected $formkeyValidator;
5454

5555
/**
56-
* @var AccountRedirect | \PHPUnit_Framework_MockObject_MockObject
56+
* @var AccountRedirect | \PHPUnit\Framework\MockObject\MockObject
5757
*/
5858
protected $accountRedirect;
5959

6060
/**
61-
* @var Http | \PHPUnit_Framework_MockObject_MockObject
61+
* @var Http | \PHPUnit\Framework\MockObject\MockObject
6262
*/
6363
protected $request;
6464

6565
/**
66-
* @var Redirect | \PHPUnit_Framework_MockObject_MockObject
66+
* @var Redirect | \PHPUnit\Framework\MockObject\MockObject
6767
*/
6868
protected $resultRedirect;
6969

7070
/**
71-
* @var \PHPUnit_Framework_MockObject_MockObject
71+
* @var \PHPUnit\Framework\MockObject\MockObject
7272
*/
7373
protected $redirectFactory;
7474

7575
/**
76-
* @var \PHPUnit_Framework_MockObject_MockObject
76+
* @var \PHPUnit\Framework\MockObject\MockObject
7777
*/
7878
protected $redirect;
7979

8080
/**
81-
* @var \Magento\Framework\Message\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject
81+
* @var \Magento\Framework\Message\ManagerInterface | \PHPUnit\Framework\MockObject\MockObject
8282
*/
8383
protected $messageManager;
8484

8585
/**
86-
* @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject
86+
* @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit\Framework\MockObject\MockObject
8787
*/
8888
protected $scopeConfig;
8989

@@ -551,14 +551,12 @@ protected function mockExceptions($exception, $username)
551551
->with($username)
552552
->willReturn($url);
553553

554-
$message = __(
555-
'This account is not confirmed.' .
556-
' <a href="%1">Click here</a> to resend confirmation email.',
557-
$url
558-
);
559554
$this->messageManager->expects($this->once())
560-
->method('addErrorMessage')
561-
->with($message)
555+
->method('addComplexErrorMessage')
556+
->with(
557+
'confirmAccountErrorMessage',
558+
['url' => $url]
559+
)
562560
->willReturnSelf();
563561

564562
$this->session->expects($this->once())

app/code/Magento/Customer/etc/frontend/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
<item name="template" xsi:type="string">Magento_Customer::messages/confirmAccountSuccessMessage.phtml</item>
9393
</item>
9494
</item>
95+
<item name="confirmAccountErrorMessage" xsi:type="array">
96+
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
97+
<item name="data" xsi:type="array">
98+
<item name="template" xsi:type="string">Magento_Customer::messages/confirmAccountErrorMessage.phtml</item>
99+
</item>
100+
</item>
95101
<item name="customerVatShippingAddressSuccessMessage" xsi:type="array">
96102
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
97103
<item name="data" xsi:type="array">
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var \Magento\Framework\View\Element\Template $block */
8+
/** @var \Magento\Framework\Escaper $escaper */
9+
10+
?>
11+
<?= $escaper->escapeHtml(
12+
__(
13+
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
14+
$block->getData('url')
15+
),
16+
['a']
17+
);

dev/tests/integration/testsuite/Magento/Catalog/Helper/OutputTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function _testAttribute($method, $entityCode, $expectedResult)
122122
try {
123123
$this->assertEquals(
124124
$expectedResult,
125-
$this->_helper->{$method}(uniqid(), "<p>line1</p>\nline2", $attributeName)
125+
$this->_helper->{$method}(uniqid(), __("<p>line1</p>\nline2"), $attributeName)
126126
);
127127

128128
$attribute->setIsHtmlAllowedOnFront($isHtml)->setIsWysiwygEnabled($isWysiwyg);

dev/tests/integration/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class LoginPostTest extends AbstractController
2828
/** @var EncoderInterface */
2929
private $urlEncoder;
3030

31+
/**
32+
* @var Url
33+
*/
34+
private $customerUrl;
35+
3136
/**
3237
* @inheritdoc
3338
*/
@@ -37,6 +42,7 @@ protected function setUp()
3742

3843
$this->session = $this->_objectManager->get(Session::class);
3944
$this->urlEncoder = $this->_objectManager->get(EncoderInterface::class);
45+
$this->customerUrl = $this->_objectManager->get(Url::class);
4046
}
4147

4248
/**
@@ -107,13 +113,16 @@ public function missingParametersDataProvider(): array
107113
*/
108114
public function testLoginWithUnconfirmedPassword(): void
109115
{
110-
$this->markTestSkipped('Blocked by MC-31370.');
111116
$email = 'unconfirmedcustomer@example.com';
112117
$this->prepareRequest($email, 'Qwert12345');
113118
$this->dispatch('customer/account/loginPost');
114119
$this->assertEquals($email, $this->session->getUsername());
120+
$message = __(
121+
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
122+
$this->customerUrl->getEmailConfirmationUrl($this->session->getUsername())
123+
);
115124
$this->assertSessionMessages(
116-
$this->equalTo([(string)__('This account is not confirmed. Click here to resend confirmation email.')]),
125+
$this->equalTo([(string)$message]),
117126
MessageInterface::TYPE_ERROR
118127
);
119128
}

0 commit comments

Comments
 (0)