6
6
7
7
namespace Magento \Ui \Test \Unit \TemplateEngine \Xhtml ;
8
8
9
+ use Magento \Framework \Serialize \Serializer \JsonHexTag ;
9
10
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
10
11
use Magento \Framework \View \Layout \Generator \Structure ;
11
12
use Magento \Framework \View \Element \UiComponentInterface ;
@@ -58,13 +59,21 @@ class ResultTest extends \PHPUnit\Framework\TestCase
58
59
*/
59
60
private $ objectManager ;
60
61
62
+ /**
63
+ * @var JsonHexTag|\PHPUnit_Framework_MockObject_MockObject
64
+ */
65
+ private $ serializer ;
66
+
61
67
protected function setUp ()
62
68
{
63
69
$ this ->template = $ this ->createPartialMock (Template::class, ['append ' ]);
64
70
$ this ->compiler = $ this ->createMock (CompilerInterface::class);
65
71
$ this ->component = $ this ->createMock (UiComponentInterface::class);
66
72
$ this ->structure = $ this ->createPartialMock (Structure::class, ['generate ' ]);
67
73
$ this ->logger = $ this ->createMock (LoggerInterface::class);
74
+ $ this ->serializer = $ this ->getMockBuilder (JsonHexTag::class)
75
+ ->disableOriginalConstructor ()
76
+ ->getMock ();
68
77
69
78
$ this ->objectManager = new ObjectManager ($ this );
70
79
$ this ->testModel = $ this ->objectManager ->getObject (Result::class, [
@@ -73,6 +82,7 @@ protected function setUp()
73
82
'component ' => $ this ->component ,
74
83
'structure ' => $ this ->structure ,
75
84
'logger ' => $ this ->logger ,
85
+ 'jsonSerializer ' => $ this ->serializer
76
86
]);
77
87
}
78
88
@@ -82,6 +92,10 @@ protected function setUp()
82
92
public function testAppendLayoutConfiguration ()
83
93
{
84
94
$ 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"] ' );
85
99
$ this ->structure ->expects ($ this ->once ())
86
100
->method ('generate ' )
87
101
->with ($ this ->component )
0 commit comments