Skip to content

Commit 31bf4b2

Browse files
committed
Fix unit test.
1 parent c3f4d5d commit 31bf4b2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/code/Magento/Ui/Test/Unit/TemplateEngine/Xhtml/ResultTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Ui\Test\Unit\TemplateEngine\Xhtml;
88

9+
use Magento\Framework\Serialize\Serializer\JsonHexTag;
910
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1011
use Magento\Framework\View\Layout\Generator\Structure;
1112
use Magento\Framework\View\Element\UiComponentInterface;
@@ -58,13 +59,21 @@ class ResultTest extends \PHPUnit\Framework\TestCase
5859
*/
5960
private $objectManager;
6061

62+
/**
63+
* @var JsonHexTag|\PHPUnit_Framework_MockObject_MockObject
64+
*/
65+
private $serializer;
66+
6167
protected function setUp()
6268
{
6369
$this->template = $this->createPartialMock(Template::class, ['append']);
6470
$this->compiler = $this->createMock(CompilerInterface::class);
6571
$this->component = $this->createMock(UiComponentInterface::class);
6672
$this->structure = $this->createPartialMock(Structure::class, ['generate']);
6773
$this->logger = $this->createMock(LoggerInterface::class);
74+
$this->serializer = $this->getMockBuilder(JsonHexTag::class)
75+
->disableOriginalConstructor()
76+
->getMock();
6877

6978
$this->objectManager = new ObjectManager($this);
7079
$this->testModel = $this->objectManager->getObject(Result::class, [
@@ -73,6 +82,7 @@ protected function setUp()
7382
'component' => $this->component,
7483
'structure' => $this->structure,
7584
'logger' => $this->logger,
85+
'jsonSerializer' => $this->serializer
7686
]);
7787
}
7888

@@ -82,6 +92,10 @@ protected function setUp()
8292
public function testAppendLayoutConfiguration()
8393
{
8494
$configWithCdata = 'text before <![CDATA[cdata text]]>';
95+
$this->serializer->expects($this->once())
96+
->method('serialize')
97+
->with([$configWithCdata])
98+
->willReturn('["text before \u003C![CDATA[cdata text]]\u003E"]');
8599
$this->structure->expects($this->once())
86100
->method('generate')
87101
->with($this->component)

0 commit comments

Comments
 (0)