17
17
use Magento \Store \Model \ScopeInterface ;
18
18
use Magento \Store \Model \Store ;
19
19
use Magento \Store \Model \StoreManagerInterface ;
20
+ use Magento \Framework \Escaper ;
20
21
21
22
/**
22
23
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -56,9 +57,19 @@ class DataTest extends \PHPUnit\Framework\TestCase
56
57
/** @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */
57
58
private $ serializerMock ;
58
59
60
+ /**
61
+ * @var \Magento\Framework\Escaper
62
+ */
63
+ private $ escaper ;
64
+
59
65
protected function setUp ()
60
66
{
61
67
$ objectManagerHelper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
68
+ $ this ->escaper = $ this ->getMockBuilder (Escaper::class)
69
+ ->disableOriginalConstructor ()
70
+ ->setMethods (['escapeHtmlAttr ' ])
71
+ ->getMock ();
72
+
62
73
$ this ->prepareContext ();
63
74
64
75
$ this ->helperDataMock = $ this ->getMockBuilder (\Magento \Directory \Helper \Data::class)
@@ -123,6 +134,8 @@ protected function prepareContext()
123
134
$ this ->contextMock ->expects ($ this ->any ())
124
135
->method ('getLayout ' )
125
136
->willReturn ($ this ->layoutMock );
137
+
138
+ $ this ->contextMock ->expects ($ this ->once ())->method ('getEscaper ' )->willReturn ($ this ->escaper );
126
139
}
127
140
128
141
protected function prepareCountryCollection ()
@@ -135,9 +148,11 @@ protected function prepareCountryCollection()
135
148
\Magento \Directory \Model \ResourceModel \Country \CollectionFactory::class
136
149
)
137
150
->disableOriginalConstructor ()
138
- ->setMethods ([
139
- 'create '
140
- ])
151
+ ->setMethods (
152
+ [
153
+ 'create '
154
+ ]
155
+ )
141
156
->getMock ();
142
157
143
158
$ this ->countryCollectionFactoryMock ->expects ($ this ->any ())
@@ -285,15 +300,17 @@ protected function mockElementHtmlSelect($defaultCountry, $options, $resultHtml)
285
300
286
301
$ elementHtmlSelect = $ this ->getMockBuilder (\Magento \Framework \View \Element \Html \Select::class)
287
302
->disableOriginalConstructor ()
288
- ->setMethods ([
289
- 'setName ' ,
290
- 'setId ' ,
291
- 'setTitle ' ,
292
- 'setValue ' ,
293
- 'setOptions ' ,
294
- 'setExtraParams ' ,
295
- 'getHtml ' ,
296
- ])
303
+ ->setMethods (
304
+ [
305
+ 'setName ' ,
306
+ 'setId ' ,
307
+ 'setTitle ' ,
308
+ 'setValue ' ,
309
+ 'setOptions ' ,
310
+ 'setExtraParams ' ,
311
+ 'getHtml '
312
+ ]
313
+ )
297
314
->getMock ();
298
315
299
316
$ elementHtmlSelect ->expects ($ this ->once ())
@@ -323,6 +340,10 @@ protected function mockElementHtmlSelect($defaultCountry, $options, $resultHtml)
323
340
$ elementHtmlSelect ->expects ($ this ->once ())
324
341
->method ('getHtml ' )
325
342
->willReturn ($ resultHtml );
343
+ $ this ->escaper ->expects ($ this ->once ())
344
+ ->method ('escapeHtmlAttr ' )
345
+ ->with (__ ($ title ))
346
+ ->willReturn (__ ($ title ));
326
347
327
348
return $ elementHtmlSelect ;
328
349
}
0 commit comments