@@ -63,7 +63,8 @@ class ProductTest extends AbstractBackendController
63
63
protected function setUp ()
64
64
{
65
65
parent ::setUp ();
66
- $ this ->productRepository = $ this ->_objectManager ->create (ProductRepositoryInterface::class);
66
+ $ this ->productRepository = $ this ->_objectManager ->get (ProductRepositoryInterface::class);
67
+ $ this ->productRepository ->cleanCache ();
67
68
$ this ->productAttributeRepository = $ this ->_objectManager ->create (ProductAttributeRepositoryInterface::class);
68
69
$ this ->registry = $ this ->_objectManager ->get (Registry::class);
69
70
$ this ->jsonSerializer = $ this ->_objectManager ->get (SerializerInterface::class);
@@ -106,7 +107,6 @@ public function testSaveNewProduct(array $childProducts): void
106
107
$ this ->assertChildProducts ($ childProducts );
107
108
$ this ->assertConfigurableOptions ('configurable ' , $ childProducts );
108
109
$ this ->assertConfigurableLinks ('configurable ' , $ this ->getProductIds (array_keys ($ childProducts )));
109
- $ this ->deleteProducts (array_merge (array_keys ($ childProducts ), ['configurable ' ]));
110
110
}
111
111
112
112
/**
@@ -157,7 +157,7 @@ public function saveNewProductDataProvider(): array
157
157
}
158
158
159
159
/**
160
- * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable_with_one_simple .php
160
+ * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_one_simple .php
161
161
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute_2.php
162
162
* @dataProvider saveExistProductDataProvider
163
163
* @param array $childProducts
@@ -176,7 +176,6 @@ public function testSaveExistProduct(array $childProducts, array $associatedProd
176
176
'configurable ' ,
177
177
$ this ->getProductIds (array_merge ($ associatedProducts , array_keys ($ childProducts )))
178
178
);
179
- $ this ->deleteProducts (array_merge ($ associatedProducts , array_keys ($ childProducts )));
180
179
}
181
180
182
181
/**
@@ -323,6 +322,7 @@ private function assertConfigurableLinks(string $sku, array $associatedProductId
323
322
private function assertRegistryConfigurableLinks (array $ associatedProductIds ): void
324
323
{
325
324
$ product = $ this ->registry ->registry ('current_product ' );
325
+ $ this ->assertNotNull ($ product );
326
326
$ this ->assertEquals (
327
327
$ associatedProductIds ,
328
328
array_values ($ product ->getExtensionAttributes ()->getConfigurableProductLinks () ?: []),
@@ -343,7 +343,7 @@ private function assertChildProducts(array $childProducts): void
343
343
$ this ->assertEquals ($ expectedProduct ['price ' ], $ product ->getPrice ());
344
344
345
345
if (!empty ($ expectedProduct ['weight ' ])) {
346
- $ this ->assertEquals ($ expectedProduct ['weight ' ], (int )$ product ->getWeight ());
346
+ $ this ->assertEquals ($ expectedProduct ['weight ' ], (double )$ product ->getWeight ());
347
347
$ this ->assertInstanceOf (Simple::class, $ product ->getTypeInstance ());
348
348
} else {
349
349
$ this ->assertInstanceOf (Virtual::class, $ product ->getTypeInstance ());
@@ -520,25 +520,4 @@ private function getProductIds(array $skuList): array
520
520
521
521
return $ associatedProductIds ;
522
522
}
523
-
524
- /**
525
- * @param array $skuList
526
- * @return void
527
- */
528
- private function deleteProducts (array $ skuList ): void
529
- {
530
- $ this ->registry ->unregister ('isSecureArea ' );
531
- $ this ->registry ->register ('isSecureArea ' , true );
532
-
533
- foreach ($ skuList as $ sku ) {
534
- try {
535
- $ product = $ this ->productRepository ->get ($ sku , false , null , true );
536
- $ this ->productRepository ->delete ($ product );
537
- } catch (NoSuchEntityException $ e ) {
538
- //Product already removed
539
- }
540
- }
541
- $ this ->registry ->unregister ('isSecureArea ' );
542
- $ this ->registry ->register ('isSecureArea ' , false );
543
- }
544
523
}
0 commit comments