Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 422a16e

Browse files
committed
MAGETWO-80179: Remove zend json from the test suite #10320
1 parent 005ec16 commit 422a16e

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
@@ -26,12 +26,12 @@ abstract class AbstractController extends \PHPUnit\Framework\TestCase
2626
protected $_runOptions = [];
2727

2828
/**
29-
* @var \Magento\TestFramework\Request
29+
* @var \Magento\Framework\App\RequestInterface
3030
*/
3131
protected $_request;
3232

3333
/**
34-
* @var \Magento\TestFramework\Response
34+
* @var \Magento\Framework\App\ResponseInterface
3535
*/
3636
protected $_response;
3737

@@ -103,7 +103,7 @@ public function dispatch($uri)
103103
/**
104104
* Request getter
105105
*
106-
* @return \Magento\TestFramework\Request
106+
* @return \Magento\Framework\App\RequestInterface
107107
*/
108108
public function getRequest()
109109
{
@@ -116,7 +116,7 @@ public function getRequest()
116116
/**
117117
* Response getter
118118
*
119-
* @return \Magento\TestFramework\Response
119+
* @return \Magento\Framework\App\ResponseInterface
120120
*/
121121
public function getResponse()
122122
{
@@ -269,14 +269,21 @@ protected function getCookieMessages($messageType = null)
269269
{
270270
/** @var $cookieManager CookieManagerInterface */
271271
$cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
272+
273+
/** @var $jsonSerializer \Magento\Framework\Serialize\Serializer\Json */
274+
$jsonSerializer = $this->_objectManager->get(\Magento\Framework\Serialize\Serializer\Json::class);
272275
try {
273-
$messages = \Zend_Json::decode(
274-
$cookieManager->getCookie(MessagePlugin::MESSAGES_COOKIES_NAME, \Zend_Json::encode([]))
276+
$messages = $jsonSerializer->unserialize(
277+
$cookieManager->getCookie(
278+
MessagePlugin::MESSAGES_COOKIES_NAME,
279+
$jsonSerializer->serialize([])
280+
)
275281
);
282+
276283
if (!is_array($messages)) {
277284
$messages = [];
278285
}
279-
} catch (\Zend_Json_Exception $e) {
286+
} catch (\InvalidArgumentException $e) {
280287
$messages = [];
281288
}
282289

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->createMock(\Magento\Framework\Message\Manager::class);
3338
$this->cookieManagerMock = $this->createMock(CookieManagerInterface::class);
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->createMock(InterpretationStrategyInterface::class);
3548
$this->interpretationStrategyMock->expects($this->any())
3649
->method('interpret')
@@ -53,6 +66,7 @@ function (MessageInterface $message) {
5366
[\Magento\Framework\App\ResponseInterface::class, $response],
5467
[\Magento\Framework\Message\Manager::class, $this->messageManager],
5568
[CookieManagerInterface::class, $this->cookieManagerMock],
69+
[\Magento\Framework\Serialize\Serializer\Json::class, $this->serializerMock],
5670
[InterpretationStrategyInterface::class, $this->interpretationStrategyMock],
5771
]
5872
)
@@ -234,6 +248,6 @@ private function addSessionMessages()
234248

235249
$this->cookieManagerMock->expects($this->any())
236250
->method('getCookie')
237-
->willReturn(\Zend_Json::encode($cookieMessages));
251+
->willReturn(json_encode($cookieMessages));
238252
}
239253
}

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

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

113113
/**

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
@@ -90,7 +90,7 @@ protected function setUp()
9090
public function testGetEntityBehaviors()
9191
{
9292
$actualEntities = $this->_model->getEntityBehaviors();
93-
$expectedEntities = \Zend_Json::encode($this->_expectedEntities);
93+
$expectedEntities = json_encode($this->_expectedEntities);
9494
$this->assertEquals($expectedEntities, $actualEntities);
9595
}
9696

@@ -102,7 +102,7 @@ public function testGetEntityBehaviors()
102102
public function testGetUniqueBehaviors()
103103
{
104104
$actualBehaviors = $this->_model->getUniqueBehaviors();
105-
$expectedBehaviors = \Zend_Json::encode($this->_expectedBehaviors);
105+
$expectedBehaviors = json_encode($this->_expectedBehaviors);
106106
$this->assertEquals($expectedBehaviors, $actualBehaviors);
107107
}
108108
}

0 commit comments

Comments
 (0)