Skip to content

Commit 97f94d2

Browse files
committed
ACP2E-3763: Investigate if AC-3637 can be automated
1 parent 07c7ce7 commit 97f94d2

File tree

2 files changed

+94
-70
lines changed

2 files changed

+94
-70
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogImportExport\Model\Import\ProductTest;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Product;
12+
use Magento\CatalogImportExport\Model\Import\ProductTestBase;
13+
use Magento\ImportExport\Model\Import;
14+
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\Framework\Exception\NoSuchEntityException;
16+
use Magento\TestFramework\Helper\Bootstrap;
17+
18+
/**
19+
* @magentoAppArea adminhtml
20+
* @magentoDbIsolation disabled
21+
* @magentoDataFixtureBeforeTransaction Magento/Catalog/_files/enable_reindex_schedule.php
22+
* @magentoDataFixtureBeforeTransaction Magento/Catalog/_files/enable_catalog_product_reindex_schedule.php
23+
*/
24+
class CustomOptionsTest extends ProductTestBase
25+
{
26+
/**
27+
* Test for custom options based on AC-3637
28+
*
29+
* @dataProvider productsWithCustomOptionsDataProvider
30+
* @param string $filename
31+
* @param string $sku
32+
* @param int $numOfCustomOptions
33+
* @throws LocalizedException
34+
* @throws NoSuchEntityException
35+
*
36+
* @return void
37+
*/
38+
public function testImportDifferentCustomOptions(string $filename, string $sku, int $numOfCustomOptions): void
39+
{
40+
$pathToFile = __DIR__ . '/../_files/' . $filename;
41+
$importModel = $this->createImportModel($pathToFile, Import::BEHAVIOR_ADD_UPDATE);
42+
$errors = $importModel->validateData();
43+
$this->assertTrue($errors->getErrorsCount() == 0);
44+
$importModel->importData();
45+
46+
/** @var ProductRepositoryInterface $productRepository */
47+
$productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
48+
$product = $productRepository->get($sku);
49+
50+
$this->assertInstanceOf(Product::class, $product);
51+
$options = $product->getOptionInstance()->getProductOptions($product);
52+
$this->assertCount($numOfCustomOptions, $options);
53+
54+
try {
55+
$this->productRepository->delete($product);
56+
} catch (NoSuchEntityException $e) {
57+
//already deleted
58+
}
59+
}
60+
61+
/**
62+
* @return array
63+
*/
64+
public static function productsWithCustomOptionsDataProvider(): array
65+
{
66+
return [
67+
[
68+
'filename' => '001_simple1_no_custom_options.csv',
69+
'sku' => 'simple1',
70+
'numOfCustomOptions' => 0,
71+
],
72+
[
73+
'filename' => '002_simple1_4_custom_options.csv',
74+
'sku' => 'simple1',
75+
'numOfCustomOptions' => 4,
76+
],
77+
[
78+
'filename' => '003_simple1_5_custom_options.csv',
79+
'sku' => 'simple1',
80+
'numOfCustomOptions' => 5,
81+
],
82+
[
83+
'filename' => '004_simple1_5_custom_options_1_updated.csv',
84+
'sku' => 'simple1',
85+
'numOfCustomOptions' => 5,
86+
],
87+
[
88+
'filename' => '005_simple1_no_custom_options.csv',
89+
'sku' => 'simple1',
90+
'numOfCustomOptions' => 0,
91+
],
92+
];
93+
}
94+
}

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

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1111
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
1212
use Magento\Catalog\Api\ProductRepositoryInterface;
13-
use Magento\Catalog\Model\Product;
1413
use Magento\Catalog\Helper\Data as CatalogConfig;
1514
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1615
use Magento\CatalogImportExport\Model\Import\ProductTestBase;
@@ -248,75 +247,6 @@ public function testSaveCustomOptionsWithMultipleStoreViews(
248247
);
249248
}
250249

251-
/**
252-
* Test for custom options based on AC-3637
253-
*
254-
* @dataProvider productsWithCustomOptionsDataProvider
255-
* @param string $filename
256-
* @param string $sku
257-
* @param int $numOfCustomOptions
258-
* @throws LocalizedException
259-
* @throws NoSuchEntityException
260-
*
261-
* @return void
262-
*/
263-
public function testImportWithoutCustomOptions(string $filename, string $sku, int $numOfCustomOptions): void
264-
{
265-
$pathToFile = __DIR__ . '/../_files/' . $filename;
266-
$importModel = $this->createImportModel($pathToFile, \Magento\ImportExport\Model\Import::BEHAVIOR_ADD_UPDATE);
267-
$errors = $importModel->validateData();
268-
$this->assertTrue($errors->getErrorsCount() == 0);
269-
$importModel->importData();
270-
271-
/** @var ProductRepositoryInterface $productRepository */
272-
$productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
273-
$product = $productRepository->get($sku);
274-
275-
$this->assertInstanceOf(Product::class, $product);
276-
$options = $product->getOptionInstance()->getProductOptions($product);
277-
$this->assertCount($numOfCustomOptions, $options);
278-
279-
try {
280-
$this->productRepository->delete($product);
281-
} catch (NoSuchEntityException $e) {
282-
//already deleted
283-
}
284-
}
285-
286-
/**
287-
* @return array
288-
*/
289-
public static function productsWithCustomOptionsDataProvider(): array
290-
{
291-
return [
292-
[
293-
'filename' => '001_simple1_no_custom_options.csv',
294-
'sku' => 'simple1',
295-
'numOfCustomOptions' => 0,
296-
],
297-
[
298-
'filename' => '002_simple1_4_custom_options.csv',
299-
'sku' => 'simple1',
300-
'numOfCustomOptions' => 4,
301-
],
302-
[
303-
'filename' => '003_simple1_5_custom_options.csv',
304-
'sku' => 'simple1',
305-
'numOfCustomOptions' => 5,
306-
],
307-
[
308-
'filename' => '004_simple1_5_custom_options_1_updated.csv',
309-
'sku' => 'simple1',
310-
'numOfCustomOptions' => 5,
311-
],
312-
[
313-
'filename' => '005_simple1_no_custom_options.csv',
314-
'sku' => 'simple1',
315-
'numOfCustomOptions' => 0,
316-
],
317-
];
318-
}
319-
320250
/**
321251
* Tests adding of custom options with multiple store views across bunches
322252
*

0 commit comments

Comments
 (0)