Skip to content

Commit eb683cf

Browse files
committed
MC-22032: Storefront: Product URL Management
1 parent 49854fe commit eb683cf

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ProductUrlRewriteTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Catalog\Api\CategoryRepositoryInterface;
1111
use Magento\Catalog\Api\Data\ProductInterface;
1212
use Magento\Catalog\Api\ProductRepositoryInterface;
13-
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
13+
use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator;
1414
use Magento\Framework\App\Config\ScopeConfigInterface;
1515
use Magento\Framework\Registry;
1616
use Magento\Store\Model\ScopeInterface;
@@ -58,7 +58,7 @@ protected function setUp()
5858
$this->categoryRepository = $this->_objectManager->create(CategoryRepositoryInterface::class);
5959
$this->storeManager = $this->_objectManager->get(StoreManagerInterface::class);
6060
$this->urlSuffix = $this->config->getValue(
61-
CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX,
61+
ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX,
6262
ScopeInterface::SCOPE_STORE
6363
);
6464
}
@@ -103,10 +103,10 @@ public function testProductRedirect(): void
103103
'url_key_create_redirect' => $product->getUrlKey(),
104104
'save_rewrites_history' => true,
105105
];
106-
$this->saveProductWithAdditionalData($product, $data);
106+
$this->updateProduct($product, $data);
107107
$this->dispatch($oldUrl);
108108

109-
$this->assertRedirect($this->stringContains('new-url-key' . $this->urlSuffix));
109+
$this->assertRedirect($this->stringContains($this->prepareUrl('new-url-key')));
110110
}
111111

112112
/**
@@ -124,7 +124,7 @@ public function testMultistoreProductUrlRewrite(): void
124124
$this->storeManager->setCurrentStore($secondStoreId);
125125

126126
try {
127-
$product = $this->saveProductWithAdditionalData($product, ['url_key' => 'second-store-url-key']);
127+
$product = $this->updateProduct($product, ['url_key' => 'second-store-url-key']);
128128
$this->assertEquals('second-store-url-key', $product->getUrlKey());
129129
$secondStoreUrl = $this->prepareUrl($product->getUrlKey());
130130

@@ -146,7 +146,7 @@ public function testMultistoreProductUrlRewrite(): void
146146
* @param array $data
147147
* @return ProductInterface
148148
*/
149-
private function saveProductWithAdditionalData(ProductInterface $product, array $data): ProductInterface
149+
private function updateProduct(ProductInterface $product, array $data): ProductInterface
150150
{
151151
$product->addData($data);
152152

@@ -195,9 +195,11 @@ private function assertProductIsVisible(ProductInterface $product): void
195195
$this->getResponse()->getHttpResponseCode(),
196196
'Wrong response code is returned'
197197
);
198+
$currentProduct = $this->registry->registry('current_product');
199+
$this->assertNotNull($currentProduct);
198200
$this->assertEquals(
199201
$product->getSku(),
200-
$this->registry->registry('current_product')->getSku(),
202+
$currentProduct->getSku(),
201203
'Wrong product is registered'
202204
);
203205
}

0 commit comments

Comments
 (0)