Skip to content

Commit

Permalink
MAGETWO-69452: Remove zend json from form elements #9754
Browse files Browse the repository at this point in the history
 - fixed unit tests
  • Loading branch information
Oleksii Korshenko committed Jun 28, 2017
1 parent 67807c1 commit d86bcde
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class EditorTest extends \PHPUnit_Framework_TestCase
*/
protected $objectManager;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $serializer;

protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand All @@ -62,13 +67,16 @@ protected function setUp()
$this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false);
$this->configMock = $this->getMock(\Magento\Framework\DataObject::class, ['getData'], [], '', false);

$this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);

$this->model = $this->objectManager->getObject(
\Magento\Framework\Data\Form\Element\Editor::class,
[
'factoryElement' => $this->factoryMock,
'factoryCollection' => $this->collectionFactoryMock,
'escaper' => $this->escaperMock,
'data' => ['config' => $this->configMock]
'data' => ['config' => $this->configMock],
'serializer' => $this->serializer
]
);

Expand Down Expand Up @@ -203,7 +211,14 @@ public function testGetConfig()
public function testGetTranslatedString()
{
$this->configMock->expects($this->any())->method('getData')->withConsecutive(['enabled'])->willReturn(true);
$this->serializer->expects($this->any())
->method('serialize')
->willReturnCallback(function ($params) {
return json_encode($params);
}
);
$html = $this->model->getElementHtml();

$this->assertRegExp('/.*"Insert Image...":"Insert Image...".*/i', $html);
}
}

0 comments on commit d86bcde

Please sign in to comment.