Skip to content
Snippets Groups Projects
Commit 2e19f33a authored by Ievgen Shakhsuvarov's avatar Ievgen Shakhsuvarov Committed by GitHub
Browse files

MAGETWO-86840: GitHub 12322: Bug with CDATA in XML layout update #1163

parents 6a48b85e ad951b0c
No related merge requests found
...@@ -119,7 +119,7 @@ class Result implements ResultInterface ...@@ -119,7 +119,7 @@ class Result implements ResultInterface
protected function wrapContent($content) protected function wrapContent($content)
{ {
return '<script type="text/x-magento-init"><![CDATA[' return '<script type="text/x-magento-init"><![CDATA['
. '{"*": {"Magento_Ui/js/core/app": ' . str_replace(['<![CDATA[', ']]>'], '', $content) . '}}' . '{"*": {"Magento_Ui/js/core/app": ' . str_replace(']]>', ']]]]><![CDATA[>', $content) . '}}'
. ']]></script>'; . ']]></script>';
} }
} }
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Ui\Test\Unit\TemplateEngine\Xhtml;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Layout\Generator\Structure;
use Magento\Framework\View\Element\UiComponentInterface;
use Magento\Framework\View\TemplateEngine\Xhtml\CompilerInterface;
use Magento\Framework\View\TemplateEngine\Xhtml\Template;
use Magento\Ui\TemplateEngine\Xhtml\Result;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
/**
* Test Class for Class Result.
* @see \Magento\Ui\TemplateEngine\Xhtml\Result
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ResultTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Template|MockObject
*/
private $template;
/**
* @var CompilerInterface|MockObject
*/
private $compiler;
/**
* @var UiComponentInterface|MockObject
*/
private $component;
/**
* @var Structure|MockObject
*/
private $structure;
/**
* @var LoggerInterface|MockObject
*/
private $logger;
/**
* @var Result
*/
private $testModel;
/**
* @var ObjectManager
*/
private $objectManager;
protected function setUp()
{
$this->template = $this->createPartialMock(Template::class, ['append']);
$this->compiler = $this->createMock(CompilerInterface::class);
$this->component = $this->createMock(UiComponentInterface::class);
$this->structure = $this->createPartialMock(Structure::class, ['generate']);
$this->logger = $this->createMock(LoggerInterface::class);
$this->objectManager = new ObjectManager($this);
$this->testModel = $this->objectManager->getObject(Result::class, [
'template' => $this->template,
'compiler' => $this->compiler,
'component' => $this->component,
'structure' => $this->structure,
'logger' => $this->logger,
]);
}
/**
* Test Append layout configuration method
*/
public function testAppendLayoutConfiguration()
{
$configWithCdata = 'text before <![CDATA[cdata text]]>';
$this->structure->expects($this->once())
->method('generate')
->with($this->component)
->willReturn([$configWithCdata]);
$this->template->expects($this->once())
->method('append')
->with('<script type="text/x-magento-init"><![CDATA[{"*": {"Magento_Ui/js/core/app": '
. '["text before <![CDATA[cdata text]]]]><![CDATA[>"]'
. '}}]]></script>');
$this->testModel->appendLayoutConfiguration();
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment