@@ -33,7 +33,7 @@ class ConfigurableTest extends TestCase
33
33
/**
34
34
* Configurable product test Type
35
35
*/
36
- const TEST_PRODUCT_TYPE = 'configurable ' ;
36
+ public const TEST_PRODUCT_TYPE = 'configurable ' ;
37
37
38
38
/**
39
39
* @var \Magento\CatalogImportExport\Model\Import\Product
@@ -59,6 +59,39 @@ protected function setUp(): void
59
59
$ this ->productMetadata = $ metadataPool ->getMetadata (ProductInterface::class);
60
60
}
61
61
62
+ /**
63
+ * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_products.php
64
+ */
65
+ public function testShouldUpdateConfigurableStockStatusIfChildProductsStockStatusChanged (): void
66
+ {
67
+ $ sku = 'configurable ' ;
68
+ /** @var ProductRepositoryInterface $productRepository */
69
+ $ productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
70
+ /** @var ProductInterface $product */
71
+ $ product = $ productRepository ->get ($ sku , true , null , true );
72
+ $ stockItem = $ this ->getStockItem ((int ) $ product ->getId ());
73
+ $ this ->assertNotNull ($ stockItem );
74
+ $ this ->assertTrue ($ stockItem ->getIsInStock ());
75
+
76
+ // Set all child product out of stock
77
+ $ pathToFile = __DIR__ . '/../../_files/import_configurable_child_products_stock_item_status_out_of_stock.csv ' ;
78
+ $ errors = $ this ->doImport ($ pathToFile );
79
+ $ this ->assertEquals (0 , $ errors ->getErrorsCount ());
80
+
81
+ $ stockItem = $ this ->getStockItem ((int ) $ product ->getId ());
82
+ $ this ->assertNotNull ($ stockItem );
83
+ $ this ->assertFalse ($ stockItem ->getIsInStock ());
84
+
85
+ // Set some child product in stock
86
+ $ pathToFile = __DIR__ . '/../../_files/import_configurable_child_products_stock_item_status_in_stock.csv ' ;
87
+ $ errors = $ this ->doImport ($ pathToFile );
88
+ $ this ->assertEquals (0 , $ errors ->getErrorsCount ());
89
+
90
+ $ stockItem = $ this ->getStockItem ((int ) $ product ->getId ());
91
+ $ this ->assertNotNull ($ stockItem );
92
+ $ this ->assertTrue ($ stockItem ->getIsInStock ());
93
+ }
94
+
62
95
public function configurableImportDataProvider ()
63
96
{
64
97
return [
@@ -202,39 +235,6 @@ public function testConfigurableImportWithStoreSpecifiedMainItem()
202
235
}
203
236
}
204
237
205
- /**
206
- * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_products.php
207
- */
208
- public function testShouldUpdateConfigurableStockStatusIfChildProductsStockStatusChanged (): void
209
- {
210
- $ sku = 'configurable ' ;
211
- /** @var ProductRepositoryInterface $productRepository */
212
- $ productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
213
- /** @var ProductInterface $product */
214
- $ product = $ productRepository ->get ($ sku , true , null , true );
215
- $ stockItem = $ this ->getStockItem ((int ) $ product ->getId ());
216
- $ this ->assertNotNull ($ stockItem );
217
- $ this ->assertTrue ($ stockItem ->getIsInStock ());
218
-
219
- // Set all child product out of stock
220
- $ pathToFile = __DIR__ . '/../../_files/import_configurable_child_products_stock_item_status_out_of_stock.csv ' ;
221
- $ errors = $ this ->doImport ($ pathToFile );
222
- $ this ->assertEquals (0 , $ errors ->getErrorsCount ());
223
-
224
- $ stockItem = $ this ->getStockItem ((int ) $ product ->getId ());
225
- $ this ->assertNotNull ($ stockItem );
226
- $ this ->assertFalse ($ stockItem ->getIsInStock ());
227
-
228
- // Set some child product in stock
229
- $ pathToFile = __DIR__ . '/../../_files/import_configurable_child_products_stock_item_status_in_stock.csv ' ;
230
- $ errors = $ this ->doImport ($ pathToFile );
231
- $ this ->assertEquals (0 , $ errors ->getErrorsCount ());
232
-
233
- $ stockItem = $ this ->getStockItem ((int ) $ product ->getId ());
234
- $ this ->assertNotNull ($ stockItem );
235
- $ this ->assertTrue ($ stockItem ->getIsInStock ());
236
- }
237
-
238
238
/**
239
239
* @param int $productId
240
240
* @return StockItemInterface|null
0 commit comments