Skip to content

Commit 256e3dd

Browse files
author
Dmytro Voskoboinikov
committed
MAGETWO-48933: use cookies to identify preview version
1 parent 8f7cb36 commit 256e3dd

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

lib/internal/Magento/Framework/Test/Unit/UrlTest.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase
1919
*/
2020
protected $routeParamsResolverMock;
2121

22+
/**
23+
* @var \Magento\Framework\Url\RouteParamsPreprocessorInterface|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
protected $routeParamsPreprocessorMock;
26+
2227
/**
2328
* @var \Magento\Framework\Url\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject
2429
*/
@@ -58,6 +63,17 @@ protected function setUp()
5863
'',
5964
false
6065
);
66+
67+
$this->routeParamsPreprocessorMock = $this->getMockForAbstractClass(
68+
'Magento\Framework\Url\RouteParamsPreprocessorInterface',
69+
[],
70+
'',
71+
false,
72+
true,
73+
true,
74+
[]
75+
);
76+
6177
$this->scopeResolverMock = $this->getMock('Magento\Framework\Url\ScopeResolverInterface');
6278
$this->scopeMock = $this->getMock('Magento\Framework\Url\ScopeInterface');
6379
$this->queryParamsResolverMock = $this->getMock(
@@ -190,7 +206,9 @@ public function testGetUrl($query, $queryResult, $returnUri)
190206
'scopeResolver' => $this->scopeResolverMock,
191207
'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
192208
'queryParamsResolver' => $this->queryParamsResolverMock,
193-
'request' => $requestMock, 'routeConfig' => $routeConfigMock,
209+
'request' => $requestMock,
210+
'routeConfig' => $routeConfigMock,
211+
'routeParamsPreprocessor' => $this->routeParamsPreprocessorMock
194212
]
195213
);
196214

@@ -204,6 +222,11 @@ public function testGetUrl($query, $queryResult, $returnUri)
204222
$this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType));
205223
$this->routeParamsResolverMock->expects($this->any())->method('getRouteParams')
206224
->will($this->returnValue(['id' => 100]));
225+
226+
$this->routeParamsPreprocessorMock->expects($this->once())
227+
->method('execute')
228+
->willReturnArgument(2);
229+
207230
$requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true));
208231
$routeConfigMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue('catalog'));
209232
$this->queryParamsResolverMock->expects($this->once())->method('getQuery')
@@ -272,12 +295,18 @@ public function testGetUrlRouteUseRewrite()
272295
{
273296
$this->routeParamsResolverMock->expects($this->any())->method('getRouteParams')
274297
->will($this->returnValue(['foo' => 'bar']));
298+
299+
$this->routeParamsPreprocessorMock->expects($this->once())
300+
->method('execute')
301+
->willReturnArgument(2);
302+
275303
$request = $this->getRequestMock();
276304
$request->expects($this->once())->method('getAlias')->will($this->returnValue('/catalog/product/view/'));
277305
$model = $this->getUrlModel([
278306
'scopeResolver' => $this->scopeResolverMock,
279307
'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
280308
'request' => $request,
309+
'routeParamsPreprocessor' => $this->routeParamsPreprocessorMock
281310
]);
282311

283312
$this->scopeResolverMock->expects($this->any())
@@ -345,7 +374,9 @@ public function testGetDirectUrl()
345374
'scopeResolver' => $this->scopeResolverMock,
346375
'routeParamsResolverFactory' => $this->getRouteParamsResolverFactory(),
347376
'queryParamsResolver' => $this->queryParamsResolverMock,
348-
'request' => $requestMock, 'routeConfig' => $routeConfigMock,
377+
'request' => $requestMock,
378+
'routeConfig' => $routeConfigMock,
379+
'routeParamsPreprocessor' => $this->routeParamsPreprocessorMock
349380
]
350381
);
351382

@@ -357,6 +388,11 @@ public function testGetDirectUrl()
357388
->method('getScope')
358389
->will($this->returnValue($this->scopeMock));
359390
$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+
360396
$requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true));
361397

362398
$url = $model->getDirectUrl('direct-url');

0 commit comments

Comments
 (0)