Skip to content

Commit

Permalink
MAGETWO-46014: delayed error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka committed May 16, 2016
1 parent 541ec80 commit 55a6e51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
35 changes: 15 additions & 20 deletions app/code/Magento/Theme/Controller/Result/MessagePlugin.php
Expand Up @@ -7,12 +7,7 @@

use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Json\Helper\Data;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;

/**
* Plugin for putting messages to cookies
Expand All @@ -25,43 +20,43 @@ class MessagePlugin
const MESSAGES_COOKIES_NAME = 'mage-messages';

/**
* @var CookieManagerInterface
* @var \Magento\Framework\Stdlib\CookieManagerInterface
*/
private $cookieManager;

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

/**
* @var ManagerInterface
* @var \Magento\Framework\Message\ManagerInterface
*/
private $messageManager;

/**
* @var InterpretationStrategyInterface
* @var \Magento\Framework\View\Element\Message\InterpretationStrategyInterface
*/
private $interpretationStrategy;

/**
* @var Data
* @var \Magento\Framework\Json\Helper\Data
*/
private $jsonHelper;

/**
* @param CookieManagerInterface $cookieManager
* @param CookieMetadataFactory $cookieMetadataFactory
* @param ManagerInterface $messageManager
* @param InterpretationStrategyInterface $interpretationStrategy
* @param Data $jsonHelper
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\Framework\View\Element\Message\InterpretationStrategyInterface $interpretationStrategy
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
*/
public function __construct(
CookieManagerInterface $cookieManager,
CookieMetadataFactory $cookieMetadataFactory,
ManagerInterface $messageManager,
InterpretationStrategyInterface $interpretationStrategy,
Data $jsonHelper
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\Framework\View\Element\Message\InterpretationStrategyInterface $interpretationStrategy,
\Magento\Framework\Json\Helper\Data $jsonHelper
) {
$this->cookieManager = $cookieManager;
$this->cookieMetadataFactory = $cookieMetadataFactory;
Expand Down
Expand Up @@ -17,6 +17,9 @@
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
use Magento\Theme\Controller\Result\MessagePlugin;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class MessagePluginTest extends \PHPUnit_Framework_TestCase
{
/** @var MessagePlugin */
Expand Down Expand Up @@ -125,16 +128,14 @@ public function testAfterRenderResult()
$this->dataMock->expects($this->any())
->method('jsonDecode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::decode($data);
}
);
$this->dataMock->expects($this->any())
->method('jsonEncode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::encode($data);
}
);
Expand Down Expand Up @@ -210,16 +211,14 @@ public function testAfterRenderResultWithoutExisting()
$this->dataMock->expects($this->any())
->method('jsonDecode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::decode($data);
}
);
$this->dataMock->expects($this->any())
->method('jsonEncode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::encode($data);
}
);
Expand Down Expand Up @@ -298,8 +297,7 @@ public function testAfterRenderResultWithWrongJson()
$this->dataMock->expects($this->any())
->method('jsonEncode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::encode($data);
}
);
Expand Down Expand Up @@ -375,16 +373,14 @@ public function testAfterRenderResultWithWrongArray()
$this->dataMock->expects($this->any())
->method('jsonDecode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::decode($data);
}
);
$this->dataMock->expects($this->any())
->method('jsonEncode')
->willReturnCallback(
function ($data)
{
function ($data) {
return \Zend_Json::encode($data);
}
);
Expand Down

0 comments on commit 55a6e51

Please sign in to comment.