Skip to content

Commit

Permalink
Fix unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Jan 16, 2019
1 parent c3f4d5d commit 31bf4b2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/code/Magento/Ui/Test/Unit/TemplateEngine/Xhtml/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

use Magento\Framework\Serialize\Serializer\JsonHexTag;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Layout\Generator\Structure;
use Magento\Framework\View\Element\UiComponentInterface;
Expand Down Expand Up @@ -58,13 +59,21 @@ class ResultTest extends \PHPUnit\Framework\TestCase
*/
private $objectManager;

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

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->serializer = $this->getMockBuilder(JsonHexTag::class)
->disableOriginalConstructor()
->getMock();

$this->objectManager = new ObjectManager($this);
$this->testModel = $this->objectManager->getObject(Result::class, [
Expand All @@ -73,6 +82,7 @@ protected function setUp()
'component' => $this->component,
'structure' => $this->structure,
'logger' => $this->logger,
'jsonSerializer' => $this->serializer
]);
}

Expand All @@ -82,6 +92,10 @@ protected function setUp()
public function testAppendLayoutConfiguration()
{
$configWithCdata = 'text before <![CDATA[cdata text]]>';
$this->serializer->expects($this->once())
->method('serialize')
->with([$configWithCdata])
->willReturn('["text before \u003C![CDATA[cdata text]]\u003E"]');
$this->structure->expects($this->once())
->method('generate')
->with($this->component)
Expand Down

0 comments on commit 31bf4b2

Please sign in to comment.