|
6 | 6 |
|
7 | 7 | namespace Magento\Store\Model; |
8 | 8 |
|
| 9 | +use Magento\Catalog\Model\ProductRepository; |
9 | 10 | use Magento\Framework\App\Bootstrap; |
| 11 | +use Magento\Framework\App\Config\ScopeConfigInterface; |
10 | 12 | use Magento\Framework\App\Filesystem\DirectoryList; |
11 | 13 | use Magento\Framework\UrlInterface; |
| 14 | +use Magento\Store\Api\StoreRepositoryInterface; |
12 | 15 | use Zend\Stdlib\Parameters; |
13 | 16 |
|
14 | 17 | /** |
@@ -268,23 +271,33 @@ public function testIsCanDelete() |
268 | 271 | } |
269 | 272 |
|
270 | 273 | /** |
271 | | - * @magentoDataFixture Magento/Store/_files/second_store.php |
| 274 | + * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php |
| 275 | + * @magentoDataFixture Magento/Catalog/_files/product_simple.php |
| 276 | + * @magentoDbIsolation disabled |
272 | 277 | */ |
273 | 278 | public function testGetCurrentUrl() |
274 | 279 | { |
| 280 | + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 281 | + $objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class) |
| 282 | + ->setValue('web/url/use_store', true, ScopeInterface::SCOPE_STORE, 'secondstore'); |
| 283 | + |
275 | 284 | $this->model->load('admin'); |
276 | 285 | $this->model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php')); |
277 | 286 | $this->assertStringEndsWith('default', $this->model->getCurrentUrl()); |
278 | 287 | $this->assertStringEndsNotWith('default', $this->model->getCurrentUrl(false)); |
279 | 288 |
|
280 | | - $this->model->load('fixture_second_store'); |
| 289 | + /** @var \Magento\Store\Model\Store $secondStore */ |
| 290 | + $secondStore = $objectManager->get(StoreRepositoryInterface::class)->get('secondstore'); |
281 | 291 |
|
282 | | - \Magento\TestFramework\Helper\Bootstrap::getObjectManager() |
283 | | - ->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class) |
284 | | - ->setValue(Store::XML_PATH_STORE_IN_URL, true, ScopeInterface::SCOPE_STORE); |
285 | | - |
286 | | - $this->assertEquals('http://localhost/index.php?___store=fixture_second_store&___from_store=default', $this->model->getCurrentUrl(true)); |
287 | | - $this->assertEquals('http://localhost/index.php?___store=fixture_second_store', $this->model->getCurrentUrl(false)); |
| 292 | + /** @var \Magento\Catalog\Model\ProductRepository $productRepository */ |
| 293 | + $productRepository = $objectManager->create(ProductRepository::class); |
| 294 | + $product = $productRepository->get('simple'); |
| 295 | + $product->setStoreId($secondStore->getId()); |
| 296 | + $url = $product->getUrlInStore(); |
| 297 | + |
| 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)); |
288 | 301 | } |
289 | 302 |
|
290 | 303 | /** |
|
0 commit comments