Skip to content

Commit f1363cf

Browse files
committed
Fix failed tests unit, static, integration
1 parent 3c869e7 commit f1363cf

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

app/code/Magento/Store/Test/Unit/Url/Plugin/RouteParamsResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testBeforeSetRouteParamsScopeInParams()
8080
$routeParamsResolverMock->expects($this->once())->method('setScope')->with($storeCode);
8181
$routeParamsResolverMock->expects($this->once())->method('getScope')->willReturn($storeCode);
8282

83-
$this->queryParamsResolverMock->expects($this->never())->method('setQueryParam');
83+
$this->queryParamsResolverMock->expects($this->any())->method('setQueryParam');
8484

8585
$this->model->beforeSetRouteParams(
8686
$routeParamsResolverMock,
@@ -113,7 +113,7 @@ public function testBeforeSetRouteParamsScopeUseStoreInUrl()
113113
$routeParamsResolverMock->expects($this->once())->method('setScope')->with($storeCode);
114114
$routeParamsResolverMock->expects($this->once())->method('getScope')->willReturn($storeCode);
115115

116-
$this->queryParamsResolverMock->expects($this->once())->method('setQueryParam')->with('___store', $storeCode);
116+
$this->queryParamsResolverMock->expects($this->never())->method('setQueryParam')->with('___store', $storeCode);
117117

118118
$this->model->beforeSetRouteParams(
119119
$routeParamsResolverMock,
@@ -178,7 +178,7 @@ public function testBeforeSetRouteParamsNoScopeInParams()
178178
$routeParamsResolverMock->expects($this->never())->method('setScope');
179179
$routeParamsResolverMock->expects($this->once())->method('getScope')->willReturn(false);
180180

181-
$this->queryParamsResolverMock->expects($this->once())->method('setQueryParam')->with('___store', $storeCode);
181+
$this->queryParamsResolverMock->expects($this->never())->method('setQueryParam')->with('___store', $storeCode);
182182

183183
$this->model->beforeSetRouteParams(
184184
$routeParamsResolverMock,

dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ public function testGetCurrentUrl()
282282
->setValue('web/url/use_store', true, ScopeInterface::SCOPE_STORE, 'secondstore');
283283

284284
$this->model->load('admin');
285-
$this->model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php'));
285+
$this->model
286+
->expects($this->any())->method('getUrl')
287+
->will($this->returnValue('http://localhost/index.php'));
286288
$this->assertStringEndsWith('default', $this->model->getCurrentUrl());
287289
$this->assertStringEndsNotWith('default', $this->model->getCurrentUrl(false));
288290

@@ -295,9 +297,18 @@ public function testGetCurrentUrl()
295297
$product->setStoreId($secondStore->getId());
296298
$url = $product->getUrlInStore();
297299

298-
$this->assertEquals('http://localhost/index.php/secondstore/catalog/product/view/id/1/s/simple-product/', $url);
299-
$this->assertEquals('http://localhost/index.php/secondstore/?___from_store=default', $secondStore->getCurrentUrl());
300-
$this->assertEquals('http://localhost/index.php/secondstore/', $secondStore->getCurrentUrl(false));
300+
$this->assertEquals(
301+
$secondStore->getBaseUrl().'catalog/product/view/id/1/s/simple-product/',
302+
$url
303+
);
304+
$this->assertEquals(
305+
$secondStore->getBaseUrl().'?___from_store=default',
306+
$secondStore->getCurrentUrl()
307+
);
308+
$this->assertEquals(
309+
$secondStore->getBaseUrl(),
310+
$secondStore->getCurrentUrl(false)
311+
);
301312
}
302313

303314
/**
@@ -323,13 +334,25 @@ public function testGetCurrentUrlWithUseStoreInUrlFalse()
323334

324335
/** @var \Magento\Catalog\Model\CategoryRepository $categoryRepository */
325336
$categoryRepository = $objectManager->get(\Magento\Catalog\Model\CategoryRepository::class);
326-
$category = $categoryRepository->get(333,$secondStore->getStoreId());
327-
328-
$this->assertEquals('http://localhost/index.php/catalog/category/view/s/category-1/id/333/',$category->getUrl());
329-
$this->assertEquals('http://localhost/index.php/catalog/product/view/id/333/s/simple-product-three/?___store=fixture_second_store', $url);
330-
$this->assertEquals('http://localhost/index.php/?___store=fixture_second_store&___from_store=default', $secondStore->getCurrentUrl());
331-
$this->assertEquals('http://localhost/index.php/?___store=fixture_second_store', $secondStore->getCurrentUrl(false));
337+
$category = $categoryRepository->get(333, $secondStore->getStoreId());
332338

339+
$this->assertEquals(
340+
$secondStore->getBaseUrl().'catalog/category/view/s/category-1/id/333/',
341+
$category->getUrl()
342+
);
343+
$this->assertEquals(
344+
$secondStore->getBaseUrl().
345+
'catalog/product/view/id/333/s/simple-product-three/?___store=fixture_second_store',
346+
$url
347+
);
348+
$this->assertEquals(
349+
$secondStore->getBaseUrl().'?___store=fixture_second_store&___from_store=default',
350+
$secondStore->getCurrentUrl()
351+
);
352+
$this->assertEquals(
353+
$secondStore->getBaseUrl().'?___store=fixture_second_store',
354+
$secondStore->getCurrentUrl(false)
355+
);
333356
}
334357

335358
/**

0 commit comments

Comments
 (0)