Skip to content

Commit

Permalink
Merge pull request #121 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[South] Bugfixing
  • Loading branch information
slavvka authored Jun 24, 2016
2 parents 7e9d181 + b50734c commit 73a5230
Show file tree
Hide file tree
Showing 19 changed files with 362 additions and 13 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Config/Model/Config/Backend/Email/Logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
namespace Magento\Config\Model\Config\Backend\Email;

/**
* @deprecated
*/
class Logo extends \Magento\Config\Model\Config\Backend\Image
{
/**
Expand Down
17 changes: 17 additions & 0 deletions app/code/Magento/Customer/Block/Account/AuthenticationPopup.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Customer\Block\Account;

use Magento\Customer\Model\Form;
use Magento\Store\Model\ScopeInterface;

class AuthenticationPopup extends \Magento\Framework\View\Element\Template
{
/**
Expand Down Expand Up @@ -40,12 +43,26 @@ public function getJsLayout()
public function getConfig()
{
return [
'autocomplete' => $this->isAutocompleteEnabled(),
'customerRegisterUrl' => $this->getCustomerRegisterUrlUrl(),
'customerForgotPasswordUrl' => $this->getCustomerForgotPasswordUrl(),
'baseUrl' => $this->getBaseUrl()
];
}

/**
* Is autocomplete enabled for storefront
*
* @return string
*/
private function isAutocompleteEnabled()
{
return $this->_scopeConfig->getValue(
Form::XML_PATH_ENABLE_AUTOCOMPLETE,
ScopeInterface::SCOPE_STORE
) ? 'on' : 'off';
}

/**
* Return base url.
*
Expand Down
48 changes: 47 additions & 1 deletion app/code/Magento/Customer/Controller/Account/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ class Confirm extends \Magento\Customer\Controller\AbstractAccount
*/
protected $session;

/**
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
*/
private $cookieMetadataFactory;

/**
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
*/
private $cookieMetadataManager;

/**
* @param Context $context
* @param Session $customerSession
Expand Down Expand Up @@ -79,6 +89,38 @@ public function __construct(
parent::__construct($context);
}

/**
* Retrieve cookie manager
*
* @deprecated
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
*/
private function getCookieManager()
{
if (!$this->cookieMetadataManager) {
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
);
}
return $this->cookieMetadataManager;
}

/**
* Retrieve cookie metadata factory
*
* @deprecated
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
*/
private function getCookieMetadataFactory()
{
if (!$this->cookieMetadataFactory) {
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
);
}
return $this->cookieMetadataFactory;
}

/**
* Confirm customer account by id and confirmation key
*
Expand All @@ -104,7 +146,11 @@ public function execute()
$customerEmail = $this->customerRepository->getById($customerId)->getEmail();
$customer = $this->customerAccountManagement->activate($customerEmail, $key);
$this->session->setCustomerDataAsLoggedIn($customer);

if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
$metadata->setPath('/');
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}
$this->messageManager->addSuccess($this->getSuccessMessage());
$resultRedirect->setUrl($this->getSuccessRedirect());
return $resultRedirect;
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Customer/Controller/Account/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function execute()
$this->session->setChangePassword($this->getRequest()->getParam('changepass') == 1);

$resultPage->getConfig()->getTitle()->set(__('Account Information'));
$resultPage->getLayout()->getBlock('messages')->setEscapeMessageFlag(true);
return $resultPage;
}
}
15 changes: 15 additions & 0 deletions app/code/Magento/Customer/Helper/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,19 @@ public function isVatAttributeVisible()
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}

/**
* Retrieve attribute visibility
*
* @param string $code
* @return bool
*/
public function isAttributeVisible($code)
{
$attributeMetadata = $this->_addressMetadataService->getAttributeMetadata($code);
if ($attributeMetadata) {
return $attributeMetadata->isVisible();
}
return false;
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ public function getPasswordConfirm()
}

/**
* Return Password Confirmation
* Return Password
*
* @return string
*/
Expand Down
7 changes: 3 additions & 4 deletions app/code/Magento/Customer/Model/EmailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
{
if ($customer->getWebsiteId() != 0 && empty($defaultStoreId)) {
$storeIds = $this->storeManager->getWebsite($customer->getWebsiteId())->getStoreIds();
reset($storeIds);
$defaultStoreId = current($storeIds);
$defaultStoreId = reset($storeIds);
}
return $defaultStoreId;
}
Expand All @@ -282,9 +281,9 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
*/
public function passwordReminder(CustomerInterface $customer)
{
$storeId = $this->storeManager->getStore()->getId();
$storeId = $this->getWebsiteStoreId($customer);
if (!$storeId) {
$storeId = $this->getWebsiteStoreId($customer);
$storeId = $this->storeManager->getStore()->getId();
}

$customerEmailData = $this->getFullCustomerObject($customer);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Test\Unit\Block\Account;

use Magento\Customer\Block\Account\AuthenticationPopup;
use Magento\Customer\Model\Form;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;

class AuthenticationPopupTest extends \PHPUnit_Framework_TestCase
{
/** @var AuthenticationPopup */
private $model;

/** @var Context|\PHPUnit_Framework_MockObject_MockObject */
private $contextMock;

/** @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
private $storeManagerMock;

/** @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
private $scopeConfigMock;

/** @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject */
private $urlBuilderMock;

protected function setUp()
{
$this->contextMock = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->getMock();

$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
->getMock();
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
->getMock();
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
->getMock();

$this->contextMock->expects($this->once())
->method('getStoreManager')
->willReturn($this->storeManagerMock);
$this->contextMock->expects($this->once())
->method('getScopeConfig')
->willReturn($this->scopeConfigMock);
$this->contextMock->expects($this->once())
->method('getUrlBuilder')
->willReturn($this->urlBuilderMock);

$this->model = new AuthenticationPopup(
$this->contextMock
);
}

/**
* @param mixed $isAutocomplete
* @param string $baseUrl
* @param string $registerUrl
* @param string $forgotUrl
* @param array $result
*
* @dataProvider dataProviderGetConfig
*/
public function testGetConfig($isAutocomplete, $baseUrl, $registerUrl, $forgotUrl, array $result)
{
$this->scopeConfigMock->expects($this->any())
->method('getValue')
->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE, null)
->willReturn($isAutocomplete);

/** @var StoreInterface||\PHPUnit_Framework_MockObject_MockObject $storeMock */
$storeMock = $this->getMockBuilder(StoreInterface::class)
->setMethods(['getBaseUrl'])
->getMockForAbstractClass();

$this->storeManagerMock->expects($this->any())
->method('getStore')
->with(null)
->willReturn($storeMock);

$storeMock->expects($this->any())
->method('getBaseUrl')
->willReturn($baseUrl);

$this->urlBuilderMock->expects($this->any())
->method('getUrl')
->willReturnMap(
[
['customer/account/create', [], $registerUrl],
['customer/account/forgotpassword', [], $forgotUrl],
]
);

$this->assertEquals($result, $this->model->getConfig());
}

public function dataProviderGetConfig()
{
return [
[
0,
'base',
'reg',
'forgot',
[
'autocomplete' => 'off',
'customerRegisterUrl' => 'reg',
'customerForgotPasswordUrl' => 'forgot',
'baseUrl' => 'base',
],
],
[
1,
'',
'reg',
'forgot',
[
'autocomplete' => 'on',
'customerRegisterUrl' => 'reg',
'customerForgotPasswordUrl' => 'forgot',
'baseUrl' => '',
],
],
[
'',
'base',
'',
'forgot',
[
'autocomplete' => 'off',
'customerRegisterUrl' => '',
'customerForgotPasswordUrl' => 'forgot',
'baseUrl' => 'base',
],
],
[
true,
'base',
'reg',
'',
[
'autocomplete' => 'on',
'customerRegisterUrl' => 'reg',
'customerForgotPasswordUrl' => '',
'baseUrl' => 'base',
],
],
];
}
}
Loading

0 comments on commit 73a5230

Please sign in to comment.