Skip to content

Commit bc0f182

Browse files
committed
Fixed failing Test Magento/Catalog/Model/Product/UrlTest.php
1 parent e2a169c commit bc0f182

File tree

1 file changed

+53
-43
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Model/Product

1 file changed

+53
-43
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/**
1212
* Test class for \Magento\Catalog\Model\Product\Url.
1313
*
14-
* @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
1514
* @magentoAppArea frontend
1615
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1716
*/
@@ -37,6 +36,9 @@ protected function setUp(): void
3736
);
3837
}
3938

39+
/**
40+
* @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
41+
*/
4042
public function testGetUrlInStore()
4143
{
4244
$repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
@@ -89,6 +91,7 @@ public function getUrlsWithSecondStoreProvider()
8991

9092
/**
9193
* @magentoDbIsolation disabled
94+
* @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
9295
*/
9396
public function testGetProductUrl()
9497
{
@@ -97,54 +100,13 @@ public function testGetProductUrl()
97100
);
98101
$product = $repository->get('simple');
99102
$this->assertStringEndsWith('simple-product.html', $this->_model->getProductUrl($product));
100-
}
101103

102-
public function testFormatUrlKey()
103-
{
104-
$this->assertEquals('abc-test', $this->_model->formatUrlKey('AbC#-$^test'));
105-
}
106-
107-
public function testGetUrlPath()
108-
{
109-
/** @var $product \Magento\Catalog\Model\Product */
110-
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
111-
\Magento\Catalog\Model\Product::class
112-
);
113-
$product->setUrlPath('product.html');
114-
115-
/** @var $category \Magento\Catalog\Model\Category */
116-
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
117-
\Magento\Catalog\Model\Category::class,
118-
['data' => ['url_path' => 'category', 'entity_id' => 5, 'path_ids' => [2, 3, 5]]]
119-
);
120-
$category->setOrigData();
121-
122-
$this->assertEquals('product.html', $this->urlPathGenerator->getUrlPath($product));
123-
$this->assertEquals('category/product.html', $this->urlPathGenerator->getUrlPath($product, $category));
124-
}
125-
126-
/**
127-
* @magentoDbIsolation disabled
128-
* @magentoAppArea frontend
129-
*/
130-
public function testGetUrl()
131-
{
132-
$repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
133-
\Magento\Catalog\Model\ProductRepository::class
134-
);
135-
$product = $repository->get('simple');
136-
$this->assertStringEndsWith('simple-product.html', $this->_model->getUrl($product));
137-
138-
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
139-
\Magento\Catalog\Model\Product::class
140-
);
141-
$product->setId(100);
142-
$this->assertStringContainsString('catalog/product/view/id/100/', $this->_model->getUrl($product));
143104
}
144105

145106
/**
146107
* Check that rearranging product url rewrites do not influence on whether to use category in product links
147108
*
109+
* @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
148110
* @magentoConfigFixture current_store catalog/seo/product_use_categories 0
149111
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
150112
* @magentoDbIsolation disabled
@@ -187,4 +149,52 @@ public function testGetProductUrlWithRearrangedUrlRewrites()
187149
$urlPersist->replace($rewrites);
188150
$this->assertStringNotContainsString($category->getUrlPath(), $this->_model->getProductUrl($product));
189151
}
152+
153+
/**
154+
* @magentoDbIsolation disabled
155+
*/
156+
public function testFormatUrlKey()
157+
{
158+
$this->assertEquals('abc-test', $this->_model->formatUrlKey('AbC#-$^test'));
159+
}
160+
161+
/**
162+
* @magentoDbIsolation disabled
163+
* @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
164+
* @magentoConfigFixture current_store catalog/seo/product_use_categories 0
165+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
166+
*/
167+
public function testGetUrl()
168+
{
169+
$repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
170+
\Magento\Catalog\Model\ProductRepository::class
171+
);
172+
$product = $repository->get('simple');
173+
$this->assertStringEndsWith('simple-product.html', $this->_model->getProductUrl($product));
174+
175+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
176+
\Magento\Catalog\Model\Product::class
177+
);
178+
$product->setId(100);
179+
$this->assertStringContainsString('catalog/product/view/id/100/', $this->_model->getUrl($product));
180+
}
181+
182+
public function testGetUrlPath()
183+
{
184+
/** @var $product \Magento\Catalog\Model\Product */
185+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
186+
\Magento\Catalog\Model\Product::class
187+
);
188+
$product->setUrlPath('product.html');
189+
190+
/** @var $category \Magento\Catalog\Model\Category */
191+
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
192+
\Magento\Catalog\Model\Category::class,
193+
['data' => ['url_path' => 'category', 'entity_id' => 5, 'path_ids' => [2, 3, 5]]]
194+
);
195+
$category->setOrigData();
196+
197+
$this->assertEquals('product.html', $this->urlPathGenerator->getUrlPath($product));
198+
$this->assertEquals('category/product.html', $this->urlPathGenerator->getUrlPath($product, $category));
199+
}
190200
}

0 commit comments

Comments
 (0)