Skip to content

Commit bc81377

Browse files
ACPT-489
fixing integration tests fixing MFTF tests
1 parent 09818fb commit bc81377

File tree

9 files changed

+83
-5
lines changed

9 files changed

+83
-5
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Category/CategoryUrlRewriteTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
* Checks category availability on storefront by url rewrite
2727
*
2828
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
29-
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
3029
* @magentoDbIsolation enabled
3130
*/
3231
class CategoryUrlRewriteTest extends AbstractController
@@ -73,6 +72,7 @@ protected function setUp(): void
7372

7473
/**
7574
* @magentoDataFixture Magento/Catalog/_files/category_tree.php
75+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
7676
* @dataProvider categoryRewriteProvider
7777
* @param int $categoryId
7878
* @param string $urlPath
@@ -118,6 +118,7 @@ public function categoryRewriteProvider(): array
118118
*
119119
* @magentoDataFixture Magento/Catalog/_files/category.php
120120
* @magentoDataFixture Magento/Store/_files/store.php
121+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
121122
* @return void
122123
*/
123124
public function testCategoryUrlOnStoreView(): void

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
/**
2323
* Checks product availability on storefront by url rewrite
2424
*
25-
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
2625
* @magentoDbIsolation enabled
2726
*/
2827
class ProductUrlRewriteTest extends AbstractController
@@ -64,6 +63,7 @@ protected function setUp(): void
6463
}
6564

6665
/**
66+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
6767
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
6868
* @return void
6969
*/
@@ -77,6 +77,7 @@ public function testProductUrlRewrite(): void
7777
}
7878

7979
/**
80+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
8081
* @magentoDataFixture Magento/Catalog/_files/category_product.php
8182
* @return void
8283
*/
@@ -91,6 +92,7 @@ public function testCategoryProductUrlRewrite(): void
9192
}
9293

9394
/**
95+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
9496
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
9597
* @return void
9698
*/
@@ -110,6 +112,7 @@ public function testProductRedirect(): void
110112
}
111113

112114
/**
115+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
113116
* @magentoDbIsolation disabled
114117
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
115118
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public function testGetUrl()
146146
* Check that rearranging product url rewrites do not influence on whether to use category in product links
147147
*
148148
* @magentoConfigFixture current_store catalog/seo/product_use_categories 0
149+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
149150
* @magentoDbIsolation disabled
150151
*/
151152
public function testGetProductUrlWithRearrangedUrlRewrites()

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest/ProductOtherTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public function testProductWithLinks()
230230
}
231231

232232
/**
233+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
233234
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
234235
* @magentoDbIsolation enabled
235236
* @magentoAppIsolation enabled
@@ -287,6 +288,65 @@ public function testUpdateUrlRewritesOnImport()
287288
}
288289
}
289290

291+
/**
292+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 0
293+
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
294+
* @magentoDbIsolation enabled
295+
* @magentoAppIsolation enabled
296+
*/
297+
public function testUpdateUrlRewritesOnImportWithoutGenerateCategoryProductRewrites()
298+
{
299+
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
300+
301+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
302+
303+
$source = $this->objectManager->create(
304+
\Magento\ImportExport\Model\Import\Source\Csv::class,
305+
[
306+
'file' => __DIR__ . '/../_files/products_to_import_with_category.csv',
307+
'directory' => $directory
308+
]
309+
);
310+
$errors = $this->_model->setParameters(
311+
[
312+
'behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
313+
'entity' => \Magento\Catalog\Model\Product::ENTITY
314+
]
315+
)->setSource(
316+
$source
317+
)->validateData();
318+
319+
$this->assertTrue($errors->getErrorsCount() == 0);
320+
321+
$this->_model->importData();
322+
323+
/** @var \Magento\Catalog\Model\Product $product */
324+
$product = $this->objectManager->create(\Magento\Catalog\Model\ProductRepository::class)->get('simple');
325+
$listOfProductUrlKeys = [
326+
sprintf('%s.html', $product->getUrlKey()),
327+
sprintf('men/tops/%s.html', $product->getUrlKey()),
328+
sprintf('men/%s.html', $product->getUrlKey())
329+
];
330+
$repUrlRewriteCol = $this->objectManager->create(
331+
UrlRewriteCollection::class
332+
);
333+
334+
/** @var UrlRewriteCollection $collUrlRewrite */
335+
$collUrlRewrite = $repUrlRewriteCol->addFieldToSelect(['request_path'])
336+
->addFieldToFilter('entity_id', ['eq'=> $product->getEntityId()])
337+
->addFieldToFilter('entity_type', ['eq'=> 'product'])
338+
->load();
339+
$listOfUrlRewriteIds = $collUrlRewrite->getAllIds();
340+
$this->assertCount(1, $collUrlRewrite);
341+
342+
foreach ($listOfUrlRewriteIds as $key => $id) {
343+
$this->assertEquals(
344+
$listOfProductUrlKeys[$key],
345+
$collUrlRewrite->getItemById($id)->getRequestPath()
346+
);
347+
}
348+
}
349+
290350
/**
291351
* @magentoAppIsolation enabled
292352
*/

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/AbstractUrlRewriteTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* Base class for url rewrites tests logic
2121
*
2222
* @magentoDbIsolation enabled
23-
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
2423
*/
2524
abstract class AbstractUrlRewriteTest extends TestCase
2625
{

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* Class for category url rewrites tests
3232
*
3333
* @magentoDbIsolation enabled
34-
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
3534
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3635
*/
3736
class CategoryUrlRewriteTest extends TestCase
@@ -82,6 +81,7 @@ protected function setUp(): void
8281
}
8382

8483
/**
84+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
8585
* @magentoDataFixture Magento/Catalog/_files/category_with_position.php
8686
* @dataProvider categoryProvider
8787
* @param array $data
@@ -147,6 +147,7 @@ public function categoryProvider(): array
147147
}
148148

149149
/**
150+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
150151
* @magentoDataFixture Magento/Catalog/_files/category_tree.php
151152
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
152153
* @dataProvider productRewriteProvider
@@ -187,6 +188,7 @@ public function productRewriteProvider(): array
187188
}
188189

189190
/**
191+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
190192
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories_with_products.php
191193
* @magentoAppIsolation enabled
192194
* @dataProvider existingUrlProvider
@@ -251,6 +253,7 @@ public function existingUrlProvider(): array
251253
}
252254

253255
/**
256+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
254257
* @magentoDataFixture Magento/Catalog/_files/category_product.php
255258
* @magentoDataFixture Magento/Catalog/_files/catalog_category_with_slash.php
256259
* @dataProvider categoryMoveProvider
@@ -310,6 +313,7 @@ public function categoryMoveProvider(): array
310313
}
311314

312315
/**
316+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
313317
* @magentoDataFixture Magento/Catalog/_files/category.php
314318
* @magentoAppArea adminhtml
315319
* @return void
@@ -326,6 +330,7 @@ public function testUrlRewritesAfterCategoryDelete(): void
326330
}
327331

328332
/**
333+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
329334
* @magentoAppArea adminhtml
330335
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories_with_product_ids.php
331336
* @return void
@@ -349,6 +354,7 @@ public function testUrlRewritesAfterCategoryWithProductsDelete(): void
349354
}
350355

351356
/**
357+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
352358
* @magentoDataFixture Magento/Store/_files/second_store.php
353359
* @magentoDataFixture Magento/Catalog/_files/category.php
354360
* @return void

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
* Class for product url rewrites tests
2929
*
3030
* @magentoDbIsolation enabled
31-
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
3231
*/
3332
class ProductUrlRewriteTest extends AbstractUrlRewriteTest
3433
{
@@ -61,6 +60,7 @@ protected function setUp(): void
6160
}
6261

6362
/**
63+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
6464
* @dataProvider productDataProvider
6565
* @param array $data
6666
* @return void
@@ -140,6 +140,7 @@ public function productDataProvider(): array
140140
}
141141

142142
/**
143+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
143144
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/product_simple.php
144145
* @dataProvider productEditProvider
145146
* @param array $expectedData
@@ -184,6 +185,7 @@ public function productEditProvider(): array
184185
}
185186

186187
/**
188+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
187189
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/category_with_products.php
188190
* @dataProvider existingUrlKeyProvider
189191
* @param array $data
@@ -242,6 +244,7 @@ public function existingUrlKeyProvider(): array
242244
}
243245

244246
/**
247+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
245248
* @magentoAppArea adminhtml
246249
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
247250
*/
@@ -257,6 +260,7 @@ public function testUrlRewritesAfterProductDelete(): void
257260
}
258261

259262
/**
263+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
260264
* @magentoDbIsolation disabled
261265
* @magentoDataFixture Magento/Store/_files/second_store.php
262266
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
@@ -282,6 +286,7 @@ public function testProductUrlRewritePerStoreViews(): void
282286
}
283287

284288
/**
289+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
285290
* Check if redirects are generated correctly while product urls are changed during import process.
286291
*
287292
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/ProcessUrlRewriteOnChangeVisibilityObserverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public function testMakeProductVisibleViaMassAction()
171171
/**
172172
* Test for multistore properties of the product to be respected in generated UrlRewrites
173173
* during the mass update for visibility change
174+
*
175+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
174176
*/
175177
#[
176178
AppIsolation(true),

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function (UrlRewrite $urlRewrite) {
8888

8989
/**
9090
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/category_with_products.php
91+
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
9192
*/
9293
public function testGenerateProductUrlRewrites2()
9394
{

0 commit comments

Comments
 (0)