Skip to content

Commit fd2c638

Browse files
committed
ACP2E-1565: [Cloud] Import Product images issues
1 parent 73a876a commit fd2c638

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ImportWithNotExistImagesTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ protected function tearDown(): void
109109

110110
/**
111111
* @magentoDataFixture Magento/Catalog/_files/product_with_image.php
112-
*
112+
* @dataProvider unexistingImagesDataProvider
113+
* @param string $imagesPath
113114
* @return void
114115
*/
115-
public function testImportWithUnexistingImages(): void
116+
public function testImportWithUnexistingImages(string $imagesPath): void
116117
{
117118
$cache = $this->objectManager->get(\Magento\Framework\App\Cache::class);
118119
$cache->clean();
@@ -132,7 +133,7 @@ public function testImportWithUnexistingImages(): void
132133
$this->assertTrue($this->directory->isExist($this->filePath), 'Products were not imported to file');
133134
$fileContent = $this->getCsvData($this->directory->getAbsolutePath($this->filePath));
134135
$this->assertCount(2, $fileContent);
135-
$this->updateFileImagesToInvalidValues();
136+
$this->updateFileImagesToInvalidValues($imagesPath);
136137
$mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA);
137138
$mediaDirectory->create('import');
138139
$this->import->setParameters([
@@ -144,6 +145,17 @@ public function testImportWithUnexistingImages(): void
144145
$this->assertProductImages('/m/a/magento_image.jpg', 'simple');
145146
}
146147

148+
/**
149+
* @return array
150+
*/
151+
public function unexistingImagesDataProvider(): array
152+
{
153+
return [
154+
['/m/a/invalid_image.jpg'],
155+
['http://127.0.0.1/pub/static/nonexistent_image.jpg'],
156+
];
157+
}
158+
147159
/**
148160
* Export products from queue to csv file
149161
*
@@ -158,9 +170,10 @@ private function exportProducts(): void
158170
/**
159171
* Change image names in an export file
160172
*
173+
* @param string $imagesPath
161174
* @return void
162175
*/
163-
private function updateFileImagesToInvalidValues(): void
176+
private function updateFileImagesToInvalidValues(string $imagesPath): void
164177
{
165178
$absolutePath = $this->directory->getAbsolutePath($this->filePath);
166179
$csv = $this->getCsvData($absolutePath);
@@ -171,7 +184,7 @@ private function updateFileImagesToInvalidValues(): void
171184
}
172185

173186
foreach ($imagesPositions as $imagesPosition) {
174-
$csv[1][$imagesPosition] = '/m/a/invalid_image.jpg';
187+
$csv[1][$imagesPosition] = $imagesPath;
175188
}
176189

177190
$this->appendCsvData($absolutePath, $csv);

0 commit comments

Comments
 (0)