Skip to content

Commit 9c5eca1

Browse files
author
Sergii Kovalenko
committed
Merge branch 'MAGETWO-53628' into BUGS
2 parents edaf7e8 + 362f62f commit 9c5eca1

File tree

5 files changed

+177
-2
lines changed

5 files changed

+177
-2
lines changed

app/code/Magento/Customer/Block/Account/AuthenticationPopup.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Customer\Block\Account;
77

8+
use Magento\Customer\Model\Form;
9+
use Magento\Store\Model\ScopeInterface;
10+
811
class AuthenticationPopup extends \Magento\Framework\View\Element\Template
912
{
1013
/**
@@ -40,12 +43,26 @@ public function getJsLayout()
4043
public function getConfig()
4144
{
4245
return [
46+
'autocomplete' => $this->isAutocompleteEnabled(),
4347
'customerRegisterUrl' => $this->getCustomerRegisterUrlUrl(),
4448
'customerForgotPasswordUrl' => $this->getCustomerForgotPasswordUrl(),
4549
'baseUrl' => $this->getBaseUrl()
4650
];
4751
}
4852

53+
/**
54+
* Is autocomplete enabled for storefront
55+
*
56+
* @return string
57+
*/
58+
private function isAutocompleteEnabled()
59+
{
60+
return $this->_scopeConfig->getValue(
61+
Form::XML_PATH_ENABLE_AUTOCOMPLETE,
62+
ScopeInterface::SCOPE_STORE
63+
) ? 'on' : 'off';
64+
}
65+
4966
/**
5067
* Return base url.
5168
*

app/code/Magento/Customer/Model/Customer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ public function getPasswordConfirm()
13401340
}
13411341

13421342
/**
1343-
* Return Password Confirmation
1343+
* Return Password
13441344
*
13451345
* @return string
13461346
*/
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Test\Unit\Block\Account;
7+
8+
use Magento\Customer\Block\Account\AuthenticationPopup;
9+
use Magento\Customer\Model\Form;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
use Magento\Framework\UrlInterface;
12+
use Magento\Framework\View\Element\Template\Context;
13+
use Magento\Store\Api\Data\StoreInterface;
14+
use Magento\Store\Model\ScopeInterface;
15+
use Magento\Store\Model\StoreManagerInterface;
16+
17+
class AuthenticationPopupTest extends \PHPUnit_Framework_TestCase
18+
{
19+
/** @var AuthenticationPopup */
20+
private $model;
21+
22+
/** @var Context|\PHPUnit_Framework_MockObject_MockObject */
23+
private $contextMock;
24+
25+
/** @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
26+
private $storeManagerMock;
27+
28+
/** @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
29+
private $scopeConfigMock;
30+
31+
/** @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject */
32+
private $urlBuilderMock;
33+
34+
protected function setUp()
35+
{
36+
$this->contextMock = $this->getMockBuilder(Context::class)
37+
->disableOriginalConstructor()
38+
->getMock();
39+
40+
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
41+
->getMock();
42+
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
43+
->getMock();
44+
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
45+
->getMock();
46+
47+
$this->contextMock->expects($this->once())
48+
->method('getStoreManager')
49+
->willReturn($this->storeManagerMock);
50+
$this->contextMock->expects($this->once())
51+
->method('getScopeConfig')
52+
->willReturn($this->scopeConfigMock);
53+
$this->contextMock->expects($this->once())
54+
->method('getUrlBuilder')
55+
->willReturn($this->urlBuilderMock);
56+
57+
$this->model = new AuthenticationPopup(
58+
$this->contextMock
59+
);
60+
}
61+
62+
/**
63+
* @param mixed $isAutocomplete
64+
* @param string $baseUrl
65+
* @param string $registerUrl
66+
* @param string $forgotUrl
67+
* @param array $result
68+
*
69+
* @dataProvider dataProviderGetConfig
70+
*/
71+
public function testGetConfig($isAutocomplete, $baseUrl, $registerUrl, $forgotUrl, array $result)
72+
{
73+
$this->scopeConfigMock->expects($this->any())
74+
->method('getValue')
75+
->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE, null)
76+
->willReturn($isAutocomplete);
77+
78+
/** @var StoreInterface||\PHPUnit_Framework_MockObject_MockObject $storeMock */
79+
$storeMock = $this->getMockBuilder(StoreInterface::class)
80+
->setMethods(['getBaseUrl'])
81+
->getMockForAbstractClass();
82+
83+
$this->storeManagerMock->expects($this->any())
84+
->method('getStore')
85+
->with(null)
86+
->willReturn($storeMock);
87+
88+
$storeMock->expects($this->any())
89+
->method('getBaseUrl')
90+
->willReturn($baseUrl);
91+
92+
$this->urlBuilderMock->expects($this->any())
93+
->method('getUrl')
94+
->willReturnMap(
95+
[
96+
['customer/account/create', [], $registerUrl],
97+
['customer/account/forgotpassword', [], $forgotUrl],
98+
]
99+
);
100+
101+
$this->assertEquals($result, $this->model->getConfig());
102+
}
103+
104+
public function dataProviderGetConfig()
105+
{
106+
return [
107+
[
108+
0,
109+
'base',
110+
'reg',
111+
'forgot',
112+
[
113+
'autocomplete' => 'off',
114+
'customerRegisterUrl' => 'reg',
115+
'customerForgotPasswordUrl' => 'forgot',
116+
'baseUrl' => 'base',
117+
],
118+
],
119+
[
120+
1,
121+
'',
122+
'reg',
123+
'forgot',
124+
[
125+
'autocomplete' => 'on',
126+
'customerRegisterUrl' => 'reg',
127+
'customerForgotPasswordUrl' => 'forgot',
128+
'baseUrl' => '',
129+
],
130+
],
131+
[
132+
'',
133+
'base',
134+
'',
135+
'forgot',
136+
[
137+
'autocomplete' => 'off',
138+
'customerRegisterUrl' => '',
139+
'customerForgotPasswordUrl' => 'forgot',
140+
'baseUrl' => 'base',
141+
],
142+
],
143+
[
144+
true,
145+
'base',
146+
'reg',
147+
'',
148+
[
149+
'autocomplete' => 'on',
150+
'customerRegisterUrl' => 'reg',
151+
'customerForgotPasswordUrl' => '',
152+
'baseUrl' => 'base',
153+
],
154+
],
155+
];
156+
}
157+
}

app/code/Magento/Customer/view/frontend/templates/account/authentication-popup.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
// @codingStandardsIgnoreFile
8+
/** @var $block \Magento\Customer\Block\Account\AuthenticationPopup */
89
?>
910
<div id="authenticationPopup" data-bind="scope:'authenticationPopup'" style="display: none;">
1011
<script>

app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ define(
2323
return Component.extend({
2424
registerUrl: window.authenticationPopup.customerRegisterUrl,
2525
forgotPasswordUrl: window.authenticationPopup.customerForgotPasswordUrl,
26-
autocomplete: window.checkout.autocomplete,
26+
autocomplete: window.authenticationPopup.autocomplete,
2727
modalWindow: null,
2828
isLoading: ko.observable(false),
2929

0 commit comments

Comments
 (0)