Skip to content

Commit d293ca4

Browse files
committed
Merge branch 'MAGETWO-58456' of github.com:magento-troll/magento2ce into MAGETWO-63344
2 parents c1f408a + 772e921 commit d293ca4

File tree

24 files changed

+769
-142
lines changed

24 files changed

+769
-142
lines changed

app/code/Magento/CatalogRule/Model/Rule.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, I
162162
* @param array $data
163163
* @param ExtensionAttributesFactory|null $extensionFactory
164164
* @param AttributeValueFactory|null $customAttributeFactory
165+
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
165166
*
166167
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
167168
*/
@@ -186,7 +187,8 @@ public function __construct(
186187
array $relatedCacheTypes = [],
187188
array $data = [],
188189
ExtensionAttributesFactory $extensionFactory = null,
189-
AttributeValueFactory $customAttributeFactory = null
190+
AttributeValueFactory $customAttributeFactory = null,
191+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
190192
) {
191193
$this->_productCollectionFactory = $productCollectionFactory;
192194
$this->_storeManager = $storeManager;
@@ -210,7 +212,8 @@ public function __construct(
210212
$resourceCollection,
211213
$data,
212214
$extensionFactory,
213-
$customAttributeFactory
215+
$customAttributeFactory,
216+
$serializer
214217
);
215218
}
216219

app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,46 @@ protected function setUp()
149149
'resourceIterator' => $this->_resourceIterator,
150150
'extensionFactory' => $extensionFactoryMock,
151151
'customAttributeFactory' => $attributeValueFactoryMock,
152+
'serializer' => $this->getSerializerMock(),
152153
]
153154
);
154155
}
155156

157+
/**
158+
* Get mock for serializer
159+
*
160+
* @return \PHPUnit_Framework_MockObject_MockObject
161+
*/
162+
private function getSerializerMock()
163+
{
164+
$serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
165+
->disableOriginalConstructor()
166+
->setMethods(['serialize', 'unserialize'])
167+
->getMock();
168+
169+
$serializerMock->expects($this->any())
170+
->method('serialize')
171+
->will(
172+
$this->returnCallback(
173+
function ($value) {
174+
return json_encode($value);
175+
}
176+
)
177+
);
178+
179+
$serializerMock->expects($this->any())
180+
->method('unserialize')
181+
->will(
182+
$this->returnCallback(
183+
function ($value) {
184+
return json_decode($value, true);
185+
}
186+
)
187+
);
188+
189+
return $serializerMock;
190+
}
191+
156192
/**
157193
* @dataProvider dataProviderCallbackValidateProduct
158194
* @param bool $validate

app/code/Magento/CatalogWidget/Model/Rule.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel
3232
* @param ExtensionAttributesFactory|null $extensionFactory
3333
* @param AttributeValueFactory|null $customAttributeFactory
3434
*
35+
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
3536
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
3637
*/
3738
public function __construct(
@@ -44,7 +45,8 @@ public function __construct(
4445
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
4546
array $data = [],
4647
ExtensionAttributesFactory $extensionFactory = null,
47-
AttributeValueFactory $customAttributeFactory = null
48+
AttributeValueFactory $customAttributeFactory = null,
49+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
4850
) {
4951
$this->conditionsFactory = $conditionsFactory;
5052
parent::__construct(
@@ -56,7 +58,8 @@ public function __construct(
5658
$resourceCollection,
5759
$data,
5860
$extensionFactory,
59-
$customAttributeFactory
61+
$customAttributeFactory,
62+
$serializer
6063
);
6164
}
6265

app/code/Magento/Cms/Helper/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function prepareResultPage(Action $action, $pageId = null)
156156

157157
$this->_eventManager->dispatch(
158158
'cms_page_render',
159-
['page' => $this->_page, 'controller_action' => $action]
159+
['page' => $this->_page, 'controller_action' => $action, 'request' => $this->_getRequest()]
160160
);
161161

162162
if ($this->_page->getCustomLayoutUpdateXml() && $inRange) {
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Test\Unit\Controller;
7+
8+
/**
9+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
10+
*/
11+
class RouterTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Cms\Controller\Router
15+
*/
16+
private $router;
17+
18+
/**
19+
* @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $eventManagerMock;
22+
23+
/**
24+
* @var \Magento\Cms\Model\PageFactory|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $pageFactoryMock;
27+
28+
/**
29+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $storeManagerMock;
32+
33+
/**
34+
* @var \Magento\Store\Api\Data\StoreInterface|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $storeMock;
37+
38+
/**
39+
* @var \Magento\Framework\App\ActionFactory|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $actionFactoryMock;
42+
43+
protected function setUp()
44+
{
45+
$this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
46+
->getMockForAbstractClass();
47+
48+
$this->pageFactoryMock = $this->getMockBuilder(\Magento\Cms\Model\PageFactory::class)
49+
->disableOriginalConstructor()
50+
->setMethods(['create'])
51+
->getMock();
52+
53+
$this->storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
54+
->getMockForAbstractClass();
55+
56+
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
57+
->getMockForAbstractClass();
58+
$this->storeManagerMock->expects($this->any())
59+
->method('getStore')
60+
->willReturn($this->storeMock);
61+
62+
$this->actionFactoryMock = $this->getMockBuilder(\Magento\Framework\App\ActionFactory::class)
63+
->disableOriginalConstructor()
64+
->getMock();
65+
66+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
67+
$this->router = $objectManagerHelper->getObject(
68+
\Magento\Cms\Controller\Router::class,
69+
[
70+
'eventManager' => $this->eventManagerMock,
71+
'pageFactory' => $this->pageFactoryMock,
72+
'storeManager' => $this->storeManagerMock,
73+
'actionFactory' => $this->actionFactoryMock,
74+
]
75+
);
76+
}
77+
78+
public function testMatchCmsControllerRouterMatchBeforeEventParams()
79+
{
80+
$identifier = '/test';
81+
$trimedIdentifier = 'test';
82+
$pageId = 1;
83+
$storeId = 1;
84+
85+
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject $requestMock */
86+
$requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
87+
->setMethods([
88+
'getPathInfo',
89+
'setModuleName',
90+
'setControllerName',
91+
'setActionName',
92+
'setParam',
93+
'setAlias',
94+
])
95+
->getMockForAbstractClass();
96+
$requestMock->expects($this->once())
97+
->method('getPathInfo')
98+
->willReturn($identifier);
99+
$requestMock->expects($this->once())
100+
->method('setModuleName')
101+
->with('cms')
102+
->willReturnSelf();
103+
$requestMock->expects($this->once())
104+
->method('setControllerName')
105+
->with('page')
106+
->willReturnSelf();
107+
$requestMock->expects($this->once())
108+
->method('setActionName')
109+
->with('view')
110+
->willReturnSelf();
111+
$requestMock->expects($this->once())
112+
->method('setParam')
113+
->with('page_id', $pageId)
114+
->willReturnSelf();
115+
$requestMock->expects($this->once())
116+
->method('setAlias')
117+
->with(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $trimedIdentifier)
118+
->willReturnSelf();
119+
120+
$condition = new \Magento\Framework\DataObject(['identifier' => $trimedIdentifier, 'continue' => true]);
121+
122+
$this->eventManagerMock->expects($this->once())
123+
->method('dispatch')
124+
->with(
125+
'cms_controller_router_match_before',
126+
[
127+
'router' => $this->router,
128+
'condition' => $condition,
129+
]
130+
)
131+
->willReturnSelf();
132+
133+
$pageMock = $this->getMockBuilder(\Magento\Cms\Model\Page::class)
134+
->disableOriginalConstructor()
135+
->getMock();
136+
$pageMock->expects($this->once())
137+
->method('checkIdentifier')
138+
->with($trimedIdentifier, $storeId)
139+
->willReturn($pageId);
140+
141+
$this->pageFactoryMock->expects($this->once())
142+
->method('create')
143+
->willReturn($pageMock);
144+
145+
$this->storeMock->expects($this->once())
146+
->method('getId')
147+
->willReturn($storeId);
148+
149+
$actionMock = $this->getMockBuilder(\Magento\Framework\App\ActionInterface::class)
150+
->getMockForAbstractClass();
151+
152+
$this->actionFactoryMock->expects($this->once())
153+
->method('create')
154+
->with(\Magento\Framework\App\Action\Forward::class)
155+
->willReturn($actionMock);
156+
157+
$this->assertEquals($actionMock, $this->router->match($requestMock));
158+
}
159+
}

app/code/Magento/Cms/Test/Unit/Helper/PageTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ class PageTest extends \PHPUnit_Framework_TestCase
113113
*/
114114
protected $resultPageFactory;
115115

116+
/**
117+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
118+
*/
119+
private $httpRequestMock;
120+
116121
protected function setUp()
117122
{
118123
$this->actionMock = $this->getMockBuilder(\Magento\Framework\App\Action\Action::class)
@@ -157,6 +162,8 @@ protected function setUp()
157162
->getMockForAbstractClass();
158163
$this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
159164
->getMockForAbstractClass();
165+
$this->httpRequestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
166+
->getMockForAbstractClass();
160167
$this->storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
161168
->disableOriginalConstructor()
162169
->getMock();
@@ -184,7 +191,8 @@ protected function setUp()
184191
\Magento\Framework\App\Helper\Context::class,
185192
[
186193
'eventManager' => $this->eventManagerMock,
187-
'urlBuilder' => $this->urlBuilderMock
194+
'urlBuilder' => $this->urlBuilderMock,
195+
'httpRequest' => $this->httpRequestMock,
188196
]
189197
);
190198

@@ -318,7 +326,8 @@ public function testPrepareResultPage(
318326
'cms_page_render',
319327
[
320328
'page' => $this->pageMock,
321-
'controller_action' => $this->actionMock
329+
'controller_action' => $this->actionMock,
330+
'request' => $this->httpRequestMock,
322331
]
323332
);
324333
$this->pageMock->expects($this->any())

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ class EditPost extends \Magento\Customer\Controller\AbstractAccount
6060
/** @var EmailNotificationInterface */
6161
private $emailNotification;
6262

63-
/**
64-
* @var ScopeConfigInterface
65-
*/
66-
private $scopeConfig;
67-
6863
/**
6964
* @var AuthenticationInterface
7065
*/
@@ -171,8 +166,7 @@ public function execute()
171166
$this->messageManager->addError($e->getMessage());
172167
} catch (UserLockedException $e) {
173168
$message = __(
174-
'The account is locked. Please wait and try again or contact %1.',
175-
$this->getScopeConfig()->getValue('contact/email/recipient_email')
169+
'You did not sign in correctly or your account is temporarily disabled.'
176170
);
177171
$this->session->logout();
178172
$this->session->start();
@@ -195,22 +189,6 @@ public function execute()
195189
return $resultRedirect->setPath('*/*/edit');
196190
}
197191

198-
/**
199-
* Get scope config
200-
*
201-
* @return ScopeConfigInterface
202-
*/
203-
private function getScopeConfig()
204-
{
205-
if (!($this->scopeConfig instanceof \Magento\Framework\App\Config\ScopeConfigInterface)) {
206-
return ObjectManager::getInstance()->get(
207-
\Magento\Framework\App\Config\ScopeConfigInterface::class
208-
);
209-
} else {
210-
return $this->scopeConfig;
211-
}
212-
}
213-
214192
/**
215193
* Account editing action completed successfully event
216194
*

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,12 @@ public function execute()
171171
$this->session->setUsername($login['username']);
172172
} catch (UserLockedException $e) {
173173
$message = __(
174-
'The account is locked. Please wait and try again or contact %1.',
175-
$this->getScopeConfig()->getValue('contact/email/recipient_email')
174+
'You did not sign in correctly or your account is temporarily disabled.'
176175
);
177176
$this->messageManager->addError($message);
178177
$this->session->setUsername($login['username']);
179178
} catch (AuthenticationException $e) {
180-
$message = __('Invalid login or password.');
179+
$message = __('You did not sign in correctly or your account is temporarily disabled.');
181180
$this->messageManager->addError($message);
182181
$this->session->setUsername($login['username']);
183182
} catch (LocalizedException $e) {

0 commit comments

Comments
 (0)