Skip to content

Commit d86bcde

Browse files
author
Oleksii Korshenko
committed
MAGETWO-69452: Remove zend json from form elements #9754
- fixed unit tests
1 parent 67807c1 commit d86bcde

File tree

1 file changed

+16
-1
lines changed
  • lib/internal/Magento/Framework/Data/Test/Unit/Form/Element

1 file changed

+16
-1
lines changed

lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class EditorTest extends \PHPUnit_Framework_TestCase
4848
*/
4949
protected $objectManager;
5050

51+
/**
52+
* @var \PHPUnit_Framework_MockObject_MockObject
53+
*/
54+
private $serializer;
55+
5156
protected function setUp()
5257
{
5358
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -62,13 +67,16 @@ protected function setUp()
6267
$this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false);
6368
$this->configMock = $this->getMock(\Magento\Framework\DataObject::class, ['getData'], [], '', false);
6469

70+
$this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
71+
6572
$this->model = $this->objectManager->getObject(
6673
\Magento\Framework\Data\Form\Element\Editor::class,
6774
[
6875
'factoryElement' => $this->factoryMock,
6976
'factoryCollection' => $this->collectionFactoryMock,
7077
'escaper' => $this->escaperMock,
71-
'data' => ['config' => $this->configMock]
78+
'data' => ['config' => $this->configMock],
79+
'serializer' => $this->serializer
7280
]
7381
);
7482

@@ -203,7 +211,14 @@ public function testGetConfig()
203211
public function testGetTranslatedString()
204212
{
205213
$this->configMock->expects($this->any())->method('getData')->withConsecutive(['enabled'])->willReturn(true);
214+
$this->serializer->expects($this->any())
215+
->method('serialize')
216+
->willReturnCallback(function ($params) {
217+
return json_encode($params);
218+
}
219+
);
206220
$html = $this->model->getElementHtml();
221+
207222
$this->assertRegExp('/.*"Insert Image...":"Insert Image...".*/i', $html);
208223
}
209224
}

0 commit comments

Comments
 (0)