Skip to content

Commit 55a6e51

Browse files
committed
MAGETWO-46014: delayed error messages
1 parent 541ec80 commit 55a6e51

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

app/code/Magento/Theme/Controller/Result/MessagePlugin.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77

88
use Magento\Framework\Controller\Result\Json;
99
use Magento\Framework\Controller\ResultInterface;
10-
use Magento\Framework\Json\Helper\Data;
11-
use Magento\Framework\Message\ManagerInterface;
1210
use Magento\Framework\Message\MessageInterface;
13-
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
14-
use Magento\Framework\Stdlib\CookieManagerInterface;
15-
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
1611

1712
/**
1813
* Plugin for putting messages to cookies
@@ -25,43 +20,43 @@ class MessagePlugin
2520
const MESSAGES_COOKIES_NAME = 'mage-messages';
2621

2722
/**
28-
* @var CookieManagerInterface
23+
* @var \Magento\Framework\Stdlib\CookieManagerInterface
2924
*/
3025
private $cookieManager;
3126

3227
/**
33-
* @var CookieMetadataFactory
28+
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
3429
*/
3530
private $cookieMetadataFactory;
3631

3732
/**
38-
* @var ManagerInterface
33+
* @var \Magento\Framework\Message\ManagerInterface
3934
*/
4035
private $messageManager;
4136

4237
/**
43-
* @var InterpretationStrategyInterface
38+
* @var \Magento\Framework\View\Element\Message\InterpretationStrategyInterface
4439
*/
4540
private $interpretationStrategy;
4641

4742
/**
48-
* @var Data
43+
* @var \Magento\Framework\Json\Helper\Data
4944
*/
5045
private $jsonHelper;
5146

5247
/**
53-
* @param CookieManagerInterface $cookieManager
54-
* @param CookieMetadataFactory $cookieMetadataFactory
55-
* @param ManagerInterface $messageManager
56-
* @param InterpretationStrategyInterface $interpretationStrategy
57-
* @param Data $jsonHelper
48+
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
49+
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
50+
* @param \Magento\Framework\Message\ManagerInterface $messageManager
51+
* @param \Magento\Framework\View\Element\Message\InterpretationStrategyInterface $interpretationStrategy
52+
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
5853
*/
5954
public function __construct(
60-
CookieManagerInterface $cookieManager,
61-
CookieMetadataFactory $cookieMetadataFactory,
62-
ManagerInterface $messageManager,
63-
InterpretationStrategyInterface $interpretationStrategy,
64-
Data $jsonHelper
55+
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
56+
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
57+
\Magento\Framework\Message\ManagerInterface $messageManager,
58+
\Magento\Framework\View\Element\Message\InterpretationStrategyInterface $interpretationStrategy,
59+
\Magento\Framework\Json\Helper\Data $jsonHelper
6560
) {
6661
$this->cookieManager = $cookieManager;
6762
$this->cookieMetadataFactory = $cookieMetadataFactory;

app/code/Magento/Theme/Test/Unit/Controller/Result/MessagePluginTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
1818
use Magento\Theme\Controller\Result\MessagePlugin;
1919

20+
/**
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
*/
2023
class MessagePluginTest extends \PHPUnit_Framework_TestCase
2124
{
2225
/** @var MessagePlugin */
@@ -125,16 +128,14 @@ public function testAfterRenderResult()
125128
$this->dataMock->expects($this->any())
126129
->method('jsonDecode')
127130
->willReturnCallback(
128-
function ($data)
129-
{
131+
function ($data) {
130132
return \Zend_Json::decode($data);
131133
}
132134
);
133135
$this->dataMock->expects($this->any())
134136
->method('jsonEncode')
135137
->willReturnCallback(
136-
function ($data)
137-
{
138+
function ($data) {
138139
return \Zend_Json::encode($data);
139140
}
140141
);
@@ -210,16 +211,14 @@ public function testAfterRenderResultWithoutExisting()
210211
$this->dataMock->expects($this->any())
211212
->method('jsonDecode')
212213
->willReturnCallback(
213-
function ($data)
214-
{
214+
function ($data) {
215215
return \Zend_Json::decode($data);
216216
}
217217
);
218218
$this->dataMock->expects($this->any())
219219
->method('jsonEncode')
220220
->willReturnCallback(
221-
function ($data)
222-
{
221+
function ($data) {
223222
return \Zend_Json::encode($data);
224223
}
225224
);
@@ -298,8 +297,7 @@ public function testAfterRenderResultWithWrongJson()
298297
$this->dataMock->expects($this->any())
299298
->method('jsonEncode')
300299
->willReturnCallback(
301-
function ($data)
302-
{
300+
function ($data) {
303301
return \Zend_Json::encode($data);
304302
}
305303
);
@@ -375,16 +373,14 @@ public function testAfterRenderResultWithWrongArray()
375373
$this->dataMock->expects($this->any())
376374
->method('jsonDecode')
377375
->willReturnCallback(
378-
function ($data)
379-
{
376+
function ($data) {
380377
return \Zend_Json::decode($data);
381378
}
382379
);
383380
$this->dataMock->expects($this->any())
384381
->method('jsonEncode')
385382
->willReturnCallback(
386-
function ($data)
387-
{
383+
function ($data) {
388384
return \Zend_Json::encode($data);
389385
}
390386
);

0 commit comments

Comments
 (0)