@@ -109,10 +109,11 @@ protected function tearDown(): void
109
109
110
110
/**
111
111
* @magentoDataFixture Magento/Catalog/_files/product_with_image.php
112
- *
112
+ * @dataProvider unexistingImagesDataProvider
113
+ * @param string $imagesPath
113
114
* @return void
114
115
*/
115
- public function testImportWithUnexistingImages (): void
116
+ public function testImportWithUnexistingImages (string $ imagesPath ): void
116
117
{
117
118
$ cache = $ this ->objectManager ->get (\Magento \Framework \App \Cache::class);
118
119
$ cache ->clean ();
@@ -132,7 +133,7 @@ public function testImportWithUnexistingImages(): void
132
133
$ this ->assertTrue ($ this ->directory ->isExist ($ this ->filePath ), 'Products were not imported to file ' );
133
134
$ fileContent = $ this ->getCsvData ($ this ->directory ->getAbsolutePath ($ this ->filePath ));
134
135
$ this ->assertCount (2 , $ fileContent );
135
- $ this ->updateFileImagesToInvalidValues ();
136
+ $ this ->updateFileImagesToInvalidValues ($ imagesPath );
136
137
$ mediaDirectory = $ this ->fileSystem ->getDirectoryWrite (DirectoryList::MEDIA );
137
138
$ mediaDirectory ->create ('import ' );
138
139
$ this ->import ->setParameters ([
@@ -144,6 +145,17 @@ public function testImportWithUnexistingImages(): void
144
145
$ this ->assertProductImages ('/m/a/magento_image.jpg ' , 'simple ' );
145
146
}
146
147
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
+
147
159
/**
148
160
* Export products from queue to csv file
149
161
*
@@ -158,9 +170,10 @@ private function exportProducts(): void
158
170
/**
159
171
* Change image names in an export file
160
172
*
173
+ * @param string $imagesPath
161
174
* @return void
162
175
*/
163
- private function updateFileImagesToInvalidValues (): void
176
+ private function updateFileImagesToInvalidValues (string $ imagesPath ): void
164
177
{
165
178
$ absolutePath = $ this ->directory ->getAbsolutePath ($ this ->filePath );
166
179
$ csv = $ this ->getCsvData ($ absolutePath );
@@ -171,7 +184,7 @@ private function updateFileImagesToInvalidValues(): void
171
184
}
172
185
173
186
foreach ($ imagesPositions as $ imagesPosition ) {
174
- $ csv [1 ][$ imagesPosition ] = ' /m/a/invalid_image.jpg ' ;
187
+ $ csv [1 ][$ imagesPosition ] = $ imagesPath ;
175
188
}
176
189
177
190
$ this ->appendCsvData ($ absolutePath , $ csv );
0 commit comments