Skip to content

Commit 7371346

Browse files
MAGETWO-71007: Remove zend json from the test suite #10320
2 parents c955c32 + 24d6028 commit 7371346

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ abstract class AbstractController extends \PHPUnit_Framework_TestCase
2525
protected $_runOptions = [];
2626

2727
/**
28-
* @var \Magento\TestFramework\Request
28+
* @var \Magento\Framework\App\RequestInterface
2929
*/
3030
protected $_request;
3131

3232
/**
33-
* @var \Magento\TestFramework\Response
33+
* @var \Magento\Framework\App\ResponseInterface
3434
*/
3535
protected $_response;
3636

@@ -102,7 +102,7 @@ public function dispatch($uri)
102102
/**
103103
* Request getter
104104
*
105-
* @return \Magento\TestFramework\Request
105+
* @return \Magento\Framework\App\RequestInterface
106106
*/
107107
public function getRequest()
108108
{
@@ -115,7 +115,7 @@ public function getRequest()
115115
/**
116116
* Response getter
117117
*
118-
* @return \Magento\TestFramework\Response
118+
* @return \Magento\Framework\App\ResponseInterface
119119
*/
120120
public function getResponse()
121121
{
@@ -268,14 +268,21 @@ protected function getCookieMessages($messageType = null)
268268
{
269269
/** @var $cookieManager CookieManagerInterface */
270270
$cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
271+
272+
/** @var $jsonSerializer \Magento\Framework\Serialize\Serializer\Json */
273+
$jsonSerializer = $this->_objectManager->get(\Magento\Framework\Serialize\Serializer\Json::class);
271274
try {
272-
$messages = \Zend_Json::decode(
273-
$cookieManager->getCookie(MessagePlugin::MESSAGES_COOKIES_NAME, \Zend_Json::encode([]))
275+
$messages = $jsonSerializer->unserialize(
276+
$cookieManager->getCookie(
277+
MessagePlugin::MESSAGES_COOKIES_NAME,
278+
$jsonSerializer->serialize([])
279+
)
274280
);
281+
275282
if (!is_array($messages)) {
276283
$messages = [];
277284
}
278-
} catch (\Zend_Json_Exception $e) {
285+
} catch (\InvalidArgumentException $e) {
279286
$messages = [];
280287
}
281288

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,25 @@ class ControllerAbstractTest extends \Magento\TestFramework\TestCase\AbstractCon
2525
/** @var \PHPUnit_Framework_MockObject_MockObject | CookieManagerInterface */
2626
private $cookieManagerMock;
2727

28+
/**
29+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Serialize\Serializer\Json
30+
*/
31+
private $serializerMock;
32+
2833
protected function setUp()
2934
{
3035
$testObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
3136

3237
$this->messageManager = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false);
3338
$this->cookieManagerMock = $this->getMock(CookieManagerInterface::class, [], [], '', false);
39+
$this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
40+
->disableOriginalConstructor()
41+
->getMock();
42+
$this->serializerMock->expects($this->any())->method('unserialize')->willReturnCallback(
43+
function ($serializedData) {
44+
return json_decode($serializedData, true);
45+
}
46+
);
3447
$this->interpretationStrategyMock = $this->getMock(InterpretationStrategyInterface::class, [], [], '', false);
3548
$this->interpretationStrategyMock->expects($this->any())
3649
->method('interpret')
@@ -58,6 +71,7 @@ function (MessageInterface $message) {
5871
[\Magento\Framework\App\ResponseInterface::class, $response],
5972
[\Magento\Framework\Message\Manager::class, $this->messageManager],
6073
[CookieManagerInterface::class, $this->cookieManagerMock],
74+
[\Magento\Framework\Serialize\Serializer\Json::class, $this->serializerMock],
6175
[InterpretationStrategyInterface::class, $this->interpretationStrategyMock],
6276
]
6377
)
@@ -244,6 +258,6 @@ private function addSessionMessages()
244258

245259
$this->cookieManagerMock->expects($this->any())
246260
->method('getCookie')
247-
->willReturn(\Zend_Json::encode($cookieMessages));
261+
->willReturn(json_encode($cookieMessages));
248262
}
249263
}

dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testLoadDefault()
108108
$this->assertNotEmpty($this->model->getTemplateText());
109109
$this->assertNotEmpty($this->model->getTemplateSubject());
110110
$this->assertNotEmpty($this->model->getOrigTemplateVariables());
111-
$this->assertInternalType('array', \Zend_Json::decode($this->model->getOrigTemplateVariables()));
111+
$this->assertInternalType('array', json_decode($this->model->getOrigTemplateVariables(), true));
112112
}
113113

114114
/**

dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Import/Edit/BeforeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function setUp()
9393
public function testGetEntityBehaviors()
9494
{
9595
$actualEntities = $this->_model->getEntityBehaviors();
96-
$expectedEntities = \Zend_Json::encode($this->_expectedEntities);
96+
$expectedEntities = json_encode($this->_expectedEntities);
9797
$this->assertEquals($expectedEntities, $actualEntities);
9898
}
9999

@@ -105,7 +105,7 @@ public function testGetEntityBehaviors()
105105
public function testGetUniqueBehaviors()
106106
{
107107
$actualBehaviors = $this->_model->getUniqueBehaviors();
108-
$expectedBehaviors = \Zend_Json::encode($this->_expectedBehaviors);
108+
$expectedBehaviors = json_encode($this->_expectedBehaviors);
109109
$this->assertEquals($expectedBehaviors, $actualBehaviors);
110110
}
111111
}

0 commit comments

Comments
 (0)