@@ -15,6 +15,11 @@ class WidgetTest extends \PHPUnit_Framework_TestCase
15
15
*/
16
16
protected $ dataStorageMock ;
17
17
18
+ /**
19
+ * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
20
+ */
21
+ private $ escaperMock ;
22
+
18
23
/**
19
24
* @var \Magento\Widget\Model\Widget
20
25
*/
@@ -27,17 +32,24 @@ class WidgetTest extends \PHPUnit_Framework_TestCase
27
32
28
33
protected function setUp ()
29
34
{
30
- $ this ->dataStorageMock = $ this ->getMockBuilder (' Magento\Widget\Model\Config\Data ' )
35
+ $ this ->dataStorageMock = $ this ->getMockBuilder (\ Magento \Widget \Model \Config \Data::class )
31
36
->disableOriginalConstructor ()
32
37
->getMock ();
33
- $ this ->conditionsHelper = $ this ->getMockBuilder (' \Magento\Widget\Helper\Conditions ' )
38
+ $ this ->conditionsHelper = $ this ->getMockBuilder (\Magento \Widget \Helper \Conditions::class )
34
39
->setMethods (['encode ' ])
35
40
->disableOriginalConstructor ()
36
41
->getMock ();
42
+ $ this ->escaperMock = $ this ->getMockBuilder (\Magento \Framework \Escaper::class)
43
+ ->disableOriginalConstructor ()
44
+ ->getMock ();
37
45
$ objectManagerHelper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
38
46
$ this ->widget = $ objectManagerHelper ->getObject (
39
- 'Magento\Widget\Model\Widget ' ,
40
- ['dataStorage ' => $ this ->dataStorageMock , 'conditionsHelper ' => $ this ->conditionsHelper ]
47
+ \Magento \Widget \Model \Widget::class,
48
+ [
49
+ 'dataStorage ' => $ this ->dataStorageMock ,
50
+ 'conditionsHelper ' => $ this ->conditionsHelper ,
51
+ 'escaper ' => $ this ->escaperMock ,
52
+ ]
41
53
);
42
54
}
43
55
@@ -160,6 +172,17 @@ public function testGetWidgetDeclaration()
160
172
161
173
$ this ->conditionsHelper ->expects ($ this ->once ())->method ('encode ' )->with ($ conditions )
162
174
->willReturn ('encoded-conditions-string ' );
175
+ $ this ->escaperMock ->expects ($ this ->atLeastOnce ())
176
+ ->method ('escapeQuote ' )
177
+ ->willReturnMap ([
178
+ ['my "widget" ' , false , 'my "widget" ' ],
179
+ ['1 ' , false , '1 ' ],
180
+ ['5 ' , false , '5 ' ],
181
+ ['10 ' , false , '10 ' ],
182
+ ['product/widget/content/grid.phtml ' , false , 'product/widget/content/grid.phtml ' ],
183
+ ['encoded-conditions-string ' , false , 'encoded-conditions-string ' ],
184
+ ]);
185
+
163
186
$ result = $ this ->widget ->getWidgetDeclaration ('Magento\CatalogWidget\Block\Product\ProductsList ' , $ params );
164
187
$ this ->assertContains ('{{widget type="Magento\CatalogWidget\Block\Product\ProductsList" ' , $ result );
165
188
$ this ->assertContains ('title="my "widget"" ' , $ result );
0 commit comments