8
8
9
9
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
10
10
use Magento \Framework \View \Asset \GroupedCollection ;
11
+ use Magento \Framework \View \Page \Config \Metadata \MsApplicationTileImage ;
11
12
use Magento \Framework \View \Page \Config \Renderer ;
12
13
use Magento \Framework \View \Page \Config \Generator ;
13
14
@@ -58,6 +59,11 @@ class RendererTest extends \PHPUnit\Framework\TestCase
58
59
*/
59
60
protected $ loggerMock ;
60
61
62
+ /**
63
+ * @var MsApplicationTileImage|\PHPUnit_Framework_MockObject_MockObject
64
+ */
65
+ protected $ msApplicationTileImageMock ;
66
+
61
67
/**
62
68
* @var \Magento\Framework\View\Asset\GroupedCollection|\PHPUnit_Framework_MockObject_MockObject
63
69
*/
@@ -99,6 +105,10 @@ protected function setUp()
99
105
$ this ->loggerMock = $ this ->getMockBuilder (\Psr \Log \LoggerInterface::class)
100
106
->getMock ();
101
107
108
+ $ this ->msApplicationTileImageMock = $ this ->getMockBuilder (MsApplicationTileImage::class)
109
+ ->disableOriginalConstructor ()
110
+ ->getMock ();
111
+
102
112
$ this ->assetsCollection = $ this ->getMockBuilder (\Magento \Framework \View \Asset \GroupedCollection::class)
103
113
->setMethods (['getGroups ' ])
104
114
->disableOriginalConstructor ()
@@ -120,7 +130,8 @@ protected function setUp()
120
130
'urlBuilder ' => $ this ->urlBuilderMock ,
121
131
'escaper ' => $ this ->escaperMock ,
122
132
'string ' => $ this ->stringMock ,
123
- 'logger ' => $ this ->loggerMock
133
+ 'logger ' => $ this ->loggerMock ,
134
+ 'msApplicationTileImage ' => $ this ->msApplicationTileImageMock
124
135
]
125
136
);
126
137
}
@@ -147,15 +158,17 @@ public function testRenderMetadata()
147
158
'content_type ' => 'content_type_value ' ,
148
159
'x_ua_compatible ' => 'x_ua_compatible_value ' ,
149
160
'media_type ' => 'media_type_value ' ,
150
- 'og:video:secure_url ' => 'secure_url '
161
+ 'og:video:secure_url ' => 'secure_url ' ,
162
+ 'msapplication-TileImage ' => 'https://site.domain/ms-tile.jpg '
151
163
];
152
164
$ metadataValueCharset = 'newCharsetValue ' ;
153
165
154
166
$ expected = '<meta charset="newCharsetValue"/> ' . "\n"
155
167
. '<meta name="metadataName" content="metadataValue"/> ' . "\n"
156
168
. '<meta http-equiv="Content-Type" content="content_type_value"/> ' . "\n"
157
169
. '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/> ' . "\n"
158
- . '<meta property="og:video:secure_url" content="secure_url"/> ' . "\n" ;
170
+ . '<meta property="og:video:secure_url" content="secure_url"/> ' . "\n"
171
+ . '<meta name="msapplication-TileImage" content="https://site.domain/ms-tile.jpg"/> ' . "\n" ;
159
172
160
173
$ this ->stringMock ->expects ($ this ->at (0 ))
161
174
->method ('upperCaseWords ' )
@@ -171,6 +184,37 @@ public function testRenderMetadata()
171
184
->method ('getMetadata ' )
172
185
->will ($ this ->returnValue ($ metadata ));
173
186
187
+ $ this ->msApplicationTileImageMock
188
+ ->expects ($ this ->once ())
189
+ ->method ('getUrl ' )
190
+ ->with ('https://site.domain/ms-tile.jpg ' )
191
+ ->will ($ this ->returnValue ('https://site.domain/ms-tile.jpg ' ));
192
+
193
+ $ this ->assertEquals ($ expected , $ this ->renderer ->renderMetadata ());
194
+ }
195
+
196
+ /**
197
+ * Test renderMetadata when it has 'msapplication-TileImage' meta passed
198
+ */
199
+ public function testRenderMetadataWithMsApplicationTileImageAsset ()
200
+ {
201
+ $ metadata = [
202
+ 'msapplication-TileImage ' => 'images/ms-tile.jpg '
203
+ ];
204
+ $ expectedMetaUrl = 'https://site.domain/images/ms-tile.jpg ' ;
205
+ $ expected = '<meta name="msapplication-TileImage" content=" ' . $ expectedMetaUrl . '"/> ' . "\n" ;
206
+
207
+ $ this ->pageConfigMock
208
+ ->expects ($ this ->once ())
209
+ ->method ('getMetadata ' )
210
+ ->will ($ this ->returnValue ($ metadata ));
211
+
212
+ $ this ->msApplicationTileImageMock
213
+ ->expects ($ this ->once ())
214
+ ->method ('getUrl ' )
215
+ ->with ('images/ms-tile.jpg ' )
216
+ ->will ($ this ->returnValue ($ expectedMetaUrl ));
217
+
174
218
$ this ->assertEquals ($ expected , $ this ->renderer ->renderMetadata ());
175
219
}
176
220
@@ -277,12 +321,14 @@ public function testRenderAssets($groupOne, $groupTwo, $expectedResult)
277
321
->willReturn ($ groupAssetsOne );
278
322
$ groupMockOne ->expects ($ this ->any ())
279
323
->method ('getProperty ' )
280
- ->willReturnMap ([
281
- [GroupedCollection::PROPERTY_CAN_MERGE , true ],
282
- [GroupedCollection::PROPERTY_CONTENT_TYPE , $ groupOne ['type ' ]],
283
- ['attributes ' , $ groupOne ['attributes ' ]],
284
- ['ie_condition ' , $ groupOne ['condition ' ]],
285
- ]);
324
+ ->willReturnMap (
325
+ [
326
+ [GroupedCollection::PROPERTY_CAN_MERGE , true ],
327
+ [GroupedCollection::PROPERTY_CONTENT_TYPE , $ groupOne ['type ' ]],
328
+ ['attributes ' , $ groupOne ['attributes ' ]],
329
+ ['ie_condition ' , $ groupOne ['condition ' ]],
330
+ ]
331
+ );
286
332
287
333
$ assetMockTwo = $ this ->createMock (\Magento \Framework \View \Asset \AssetInterface::class);
288
334
$ assetMockTwo ->expects ($ this ->once ())
@@ -300,12 +346,14 @@ public function testRenderAssets($groupOne, $groupTwo, $expectedResult)
300
346
->willReturn ($ groupAssetsTwo );
301
347
$ groupMockTwo ->expects ($ this ->any ())
302
348
->method ('getProperty ' )
303
- ->willReturnMap ([
304
- [GroupedCollection::PROPERTY_CAN_MERGE , true ],
305
- [GroupedCollection::PROPERTY_CONTENT_TYPE , $ groupTwo ['type ' ]],
306
- ['attributes ' , $ groupTwo ['attributes ' ]],
307
- ['ie_condition ' , $ groupTwo ['condition ' ]],
308
- ]);
349
+ ->willReturnMap (
350
+ [
351
+ [GroupedCollection::PROPERTY_CAN_MERGE , true ],
352
+ [GroupedCollection::PROPERTY_CONTENT_TYPE , $ groupTwo ['type ' ]],
353
+ ['attributes ' , $ groupTwo ['attributes ' ]],
354
+ ['ie_condition ' , $ groupTwo ['condition ' ]],
355
+ ]
356
+ );
309
357
310
358
$ this ->pageConfigMock ->expects ($ this ->once ())
311
359
->method ('getAssetCollection ' )
0 commit comments