Skip to content

Commit 73a5230

Browse files
authored
Merge pull request #121 from magento-south/BUGS
[South] Bugfixing
2 parents 7e9d181 + b50734c commit 73a5230

File tree

19 files changed

+362
-13
lines changed

19 files changed

+362
-13
lines changed

app/code/Magento/Config/Model/Config/Backend/Email/Logo.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\Config\Model\Config\Backend\Email;
1313

14+
/**
15+
* @deprecated
16+
*/
1417
class Logo extends \Magento\Config\Model\Config\Backend\Image
1518
{
1619
/**

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

+17
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/Controller/Account/Confirm.php

+47-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ class Confirm extends \Magento\Customer\Controller\AbstractAccount
4949
*/
5050
protected $session;
5151

52+
/**
53+
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
54+
*/
55+
private $cookieMetadataFactory;
56+
57+
/**
58+
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
59+
*/
60+
private $cookieMetadataManager;
61+
5262
/**
5363
* @param Context $context
5464
* @param Session $customerSession
@@ -79,6 +89,38 @@ public function __construct(
7989
parent::__construct($context);
8090
}
8191

92+
/**
93+
* Retrieve cookie manager
94+
*
95+
* @deprecated
96+
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
97+
*/
98+
private function getCookieManager()
99+
{
100+
if (!$this->cookieMetadataManager) {
101+
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
102+
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
103+
);
104+
}
105+
return $this->cookieMetadataManager;
106+
}
107+
108+
/**
109+
* Retrieve cookie metadata factory
110+
*
111+
* @deprecated
112+
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
113+
*/
114+
private function getCookieMetadataFactory()
115+
{
116+
if (!$this->cookieMetadataFactory) {
117+
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
118+
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
119+
);
120+
}
121+
return $this->cookieMetadataFactory;
122+
}
123+
82124
/**
83125
* Confirm customer account by id and confirmation key
84126
*
@@ -104,7 +146,11 @@ public function execute()
104146
$customerEmail = $this->customerRepository->getById($customerId)->getEmail();
105147
$customer = $this->customerAccountManagement->activate($customerEmail, $key);
106148
$this->session->setCustomerDataAsLoggedIn($customer);
107-
149+
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
150+
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
151+
$metadata->setPath('/');
152+
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
153+
}
108154
$this->messageManager->addSuccess($this->getSuccessMessage());
109155
$resultRedirect->setUrl($this->getSuccessRedirect());
110156
return $resultRedirect;

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

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public function execute()
8080
$this->session->setChangePassword($this->getRequest()->getParam('changepass') == 1);
8181

8282
$resultPage->getConfig()->getTitle()->set(__('Account Information'));
83-
$resultPage->getLayout()->getBlock('messages')->setEscapeMessageFlag(true);
8483
return $resultPage;
8584
}
8685
}

app/code/Magento/Customer/Helper/Address.php

+15
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,19 @@ public function isVatAttributeVisible()
373373
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
374374
);
375375
}
376+
377+
/**
378+
* Retrieve attribute visibility
379+
*
380+
* @param string $code
381+
* @return bool
382+
*/
383+
public function isAttributeVisible($code)
384+
{
385+
$attributeMetadata = $this->_addressMetadataService->getAttributeMetadata($code);
386+
if ($attributeMetadata) {
387+
return $attributeMetadata->isVisible();
388+
}
389+
return false;
390+
}
376391
}

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

+1-1
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
*/

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
268268
{
269269
if ($customer->getWebsiteId() != 0 && empty($defaultStoreId)) {
270270
$storeIds = $this->storeManager->getWebsite($customer->getWebsiteId())->getStoreIds();
271-
reset($storeIds);
272-
$defaultStoreId = current($storeIds);
271+
$defaultStoreId = reset($storeIds);
273272
}
274273
return $defaultStoreId;
275274
}
@@ -282,9 +281,9 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
282281
*/
283282
public function passwordReminder(CustomerInterface $customer)
284283
{
285-
$storeId = $this->storeManager->getStore()->getId();
284+
$storeId = $this->getWebsiteStoreId($customer);
286285
if (!$storeId) {
287-
$storeId = $this->getWebsiteStoreId($customer);
286+
$storeId = $this->storeManager->getStore()->getId();
288287
}
289288

290289
$customerEmailData = $this->getFullCustomerObject($customer);
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+
}

0 commit comments

Comments
 (0)