@@ -19,6 +19,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase
19
19
*/
20
20
protected $ routeParamsResolverMock ;
21
21
22
+ /**
23
+ * @var \Magento\Framework\Url\RouteParamsPreprocessorInterface|\PHPUnit_Framework_MockObject_MockObject
24
+ */
25
+ protected $ routeParamsPreprocessorMock ;
26
+
22
27
/**
23
28
* @var \Magento\Framework\Url\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject
24
29
*/
@@ -58,6 +63,17 @@ protected function setUp()
58
63
'' ,
59
64
false
60
65
);
66
+
67
+ $ this ->routeParamsPreprocessorMock = $ this ->getMockForAbstractClass (
68
+ 'Magento\Framework\Url\RouteParamsPreprocessorInterface ' ,
69
+ [],
70
+ '' ,
71
+ false ,
72
+ true ,
73
+ true ,
74
+ []
75
+ );
76
+
61
77
$ this ->scopeResolverMock = $ this ->getMock ('Magento\Framework\Url\ScopeResolverInterface ' );
62
78
$ this ->scopeMock = $ this ->getMock ('Magento\Framework\Url\ScopeInterface ' );
63
79
$ this ->queryParamsResolverMock = $ this ->getMock (
@@ -190,7 +206,9 @@ public function testGetUrl($query, $queryResult, $returnUri)
190
206
'scopeResolver ' => $ this ->scopeResolverMock ,
191
207
'routeParamsResolverFactory ' => $ this ->getRouteParamsResolverFactory (),
192
208
'queryParamsResolver ' => $ this ->queryParamsResolverMock ,
193
- 'request ' => $ requestMock , 'routeConfig ' => $ routeConfigMock ,
209
+ 'request ' => $ requestMock ,
210
+ 'routeConfig ' => $ routeConfigMock ,
211
+ 'routeParamsPreprocessor ' => $ this ->routeParamsPreprocessorMock
194
212
]
195
213
);
196
214
@@ -204,6 +222,11 @@ public function testGetUrl($query, $queryResult, $returnUri)
204
222
$ this ->routeParamsResolverMock ->expects ($ this ->any ())->method ('getType ' )->will ($ this ->returnValue ($ urlType ));
205
223
$ this ->routeParamsResolverMock ->expects ($ this ->any ())->method ('getRouteParams ' )
206
224
->will ($ this ->returnValue (['id ' => 100 ]));
225
+
226
+ $ this ->routeParamsPreprocessorMock ->expects ($ this ->once ())
227
+ ->method ('execute ' )
228
+ ->willReturnArgument (2 );
229
+
207
230
$ requestMock ->expects ($ this ->once ())->method ('isDirectAccessFrontendName ' )->will ($ this ->returnValue (true ));
208
231
$ routeConfigMock ->expects ($ this ->once ())->method ('getRouteFrontName ' )->will ($ this ->returnValue ('catalog ' ));
209
232
$ this ->queryParamsResolverMock ->expects ($ this ->once ())->method ('getQuery ' )
@@ -272,12 +295,18 @@ public function testGetUrlRouteUseRewrite()
272
295
{
273
296
$ this ->routeParamsResolverMock ->expects ($ this ->any ())->method ('getRouteParams ' )
274
297
->will ($ this ->returnValue (['foo ' => 'bar ' ]));
298
+
299
+ $ this ->routeParamsPreprocessorMock ->expects ($ this ->once ())
300
+ ->method ('execute ' )
301
+ ->willReturnArgument (2 );
302
+
275
303
$ request = $ this ->getRequestMock ();
276
304
$ request ->expects ($ this ->once ())->method ('getAlias ' )->will ($ this ->returnValue ('/catalog/product/view/ ' ));
277
305
$ model = $ this ->getUrlModel ([
278
306
'scopeResolver ' => $ this ->scopeResolverMock ,
279
307
'routeParamsResolverFactory ' => $ this ->getRouteParamsResolverFactory (),
280
308
'request ' => $ request ,
309
+ 'routeParamsPreprocessor ' => $ this ->routeParamsPreprocessorMock
281
310
]);
282
311
283
312
$ this ->scopeResolverMock ->expects ($ this ->any ())
@@ -345,7 +374,9 @@ public function testGetDirectUrl()
345
374
'scopeResolver ' => $ this ->scopeResolverMock ,
346
375
'routeParamsResolverFactory ' => $ this ->getRouteParamsResolverFactory (),
347
376
'queryParamsResolver ' => $ this ->queryParamsResolverMock ,
348
- 'request ' => $ requestMock , 'routeConfig ' => $ routeConfigMock ,
377
+ 'request ' => $ requestMock ,
378
+ 'routeConfig ' => $ routeConfigMock ,
379
+ 'routeParamsPreprocessor ' => $ this ->routeParamsPreprocessorMock
349
380
]
350
381
);
351
382
@@ -357,6 +388,11 @@ public function testGetDirectUrl()
357
388
->method ('getScope ' )
358
389
->will ($ this ->returnValue ($ this ->scopeMock ));
359
390
$ this ->routeParamsResolverMock ->expects ($ this ->any ())->method ('getType ' )->will ($ this ->returnValue ($ urlType ));
391
+
392
+ $ this ->routeParamsPreprocessorMock ->expects ($ this ->once ())
393
+ ->method ('execute ' )
394
+ ->willReturnArgument (2 );
395
+
360
396
$ requestMock ->expects ($ this ->once ())->method ('isDirectAccessFrontendName ' )->will ($ this ->returnValue (true ));
361
397
362
398
$ url = $ model ->getDirectUrl ('direct-url ' );
0 commit comments