Skip to content

Commit eb623e0

Browse files
MC-29265: Admin: Add/delete image(s) from configurable product and its child products
1 parent b26be92 commit eb623e0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function setUp()
101101
$this->productRepository->cleanCache();
102102
$this->productResource =$this->objectManager->get(ProductResource::class);
103103
$this->productAttributeRepository = $this->objectManager->create(ProductAttributeRepositoryInterface::class);
104-
$this->jsonSerializer = $this->objectManager->create(SerializerInterface::class);
104+
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
105105
$this->searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
106106
$this->config = $this->objectManager->get(Config::class);
107107
$this->mediaDirectory = $this->objectManager->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA);
@@ -130,12 +130,12 @@ public function testInitialize(array $childProducts, array $expectedImages): voi
130130
*
131131
* @magentoDataFixture Magento/Catalog/_files/product_image.php
132132
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
133-
* @dataProvider initializeWithExistChildImagesDataProvider
133+
* @dataProvider initializeWithExistingChildImagesDataProvider
134134
* @param array $childProducts
135135
* @param array $expectedImages
136136
* @return void
137137
*/
138-
public function testInitializeWithExistChildImages(array $childProducts, array $expectedImages): void
138+
public function testInitializeWithExistingChildImages(array $childProducts, array $expectedImages): void
139139
{
140140
$this->updateChildProductsImages(
141141
[
@@ -248,7 +248,7 @@ public function initializeDataProvider(): array
248248
/**
249249
* @return array
250250
*/
251-
public function initializeWithExistChildImagesDataProvider(): array
251+
public function initializeWithExistingChildImagesDataProvider(): array
252252
{
253253
$dataProvider = $this->initializeDataProvider();
254254
unset($dataProvider['children_with_different_images'], $dataProvider['children_with_different_image_roles']);
@@ -348,7 +348,8 @@ private function updateChildProductsImages(array $imageNames): void
348348
{
349349
$simpleIds = $this->configurableProduct->getExtensionAttributes()->getConfigurableProductLinks();
350350
$criteria = $this->searchCriteriaBuilder->addFilter('entity_id', $simpleIds, 'in')->create();
351-
foreach ($this->productRepository->getList($criteria)->getItems() as $simpleProduct) {
351+
$products = $this->productRepository->getList($criteria)->getItems();
352+
foreach ($products as $simpleProduct) {
352353
$simpleProduct->setStoreId(Store::DEFAULT_STORE_ID)
353354
->setImage($imageNames[$simpleProduct->getSku()])
354355
->setSmallImage($imageNames[$simpleProduct->getSku()])

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/VariationHandlerTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ protected function setUp()
5858
$this->productRepository->cleanCache();
5959
$this->variationHandler = $this->objectManager->create(VariationHandler::class);
6060
$this->product = $this->productRepository->get('configurable');
61-
$this->product->setTypeInstance($this->objectManager->create(Configurable::class));
6261
$this->stockRegistry = $this->objectManager->get(StockRegistryInterface::class);
6362
}
6463

@@ -71,10 +70,10 @@ protected function setUp()
7170
public function testGenerateSimpleProducts(array $productsData): void
7271
{
7372
$this->product->setImage('some_test_image.jpg')
74-
->setSmallImage('some_test_image.jpg')
75-
->setThumbnail('some_test_image.jpg')
76-
->setSwatchImage('some_test_image.jpg')
77-
->setNewVariationsAttributeSetId($this->product->getDefaultAttributeSetId());
73+
->setSmallImage('some_test_image.jpg')
74+
->setThumbnail('some_test_image.jpg')
75+
->setSwatchImage('some_test_image.jpg')
76+
->setNewVariationsAttributeSetId($this->product->getDefaultAttributeSetId());
7877
$generatedProducts = $this->variationHandler->generateSimpleProducts($this->product, $productsData);
7978
$this->assertEquals(3, count($generatedProducts));
8079
foreach ($generatedProducts as $productId) {

0 commit comments

Comments
 (0)