Skip to content

Commit 0ee4f6b

Browse files
committed
B2B-2023: [AWS S3] [Integration Tests]: Investigate Test Failures in CatalogImportExport module
1 parent 5e20120 commit 0ee4f6b

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function assertProductImages(string $imageName, string $productSku): voi
237237
private function getCsvData(string $filePath): array
238238
{
239239
$driver = $this->directory->getDriver();
240-
$fileResource = $driver->fileOpen($filePath, null);
240+
$fileResource = $driver->fileOpen($filePath, 'r');
241241

242242
$data = [];
243243
while ($rowData = $driver->fileGetCsv($fileResource, 100000)) {
@@ -258,7 +258,7 @@ private function getCsvData(string $filePath): array
258258
private function appendCsvData(string $filePath, array $csv): void
259259
{
260260
$driver = $this->directory->getDriver();
261-
$fileResource = $driver->fileOpen($filePath, null);
261+
$fileResource = $driver->fileOpen($filePath, 'w');
262262

263263
foreach ($csv as $dataRow) {
264264
$driver->filePutCsv($fileResource, $dataRow);

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -288,35 +288,20 @@ protected function importDataForMediaTest(string $fileName, int $expectedErrors
288288
'directory' => $directory
289289
]
290290
);
291-
$rootDirectory = $this->objectManager->get(TargetDirectory::class)->getDirectoryWrite(DirectoryList::ROOT);
291+
$mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
292+
$mediaDirPath = $this->getMediaDirPath($mediaDirectory);
293+
$destDir = $mediaDirPath . DIRECTORY_SEPARATOR . 'catalog' . DIRECTORY_SEPARATOR . 'product';
294+
$tmpDir = $mediaDirPath . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . 'images';
295+
$mediaDirectory->create('catalog' . DIRECTORY_SEPARATOR . 'product');
296+
$mediaDirectory->create('import' . DIRECTORY_SEPARATOR . 'images');
297+
292298
$this->_model->setParameters(
293299
[
294300
'behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
295301
'entity' => 'catalog_product',
296-
Import::FIELD_NAME_IMG_FILE_DIR => $this->getMediaDirPath($rootDirectory) . '/import'
302+
Import::FIELD_NAME_IMG_FILE_DIR => $mediaDirPath . '/import'
297303
]
298304
);
299-
$appParams = \Magento\TestFramework\Helper\Bootstrap::getInstance()
300-
->getBootstrap()
301-
->getApplication()
302-
->getInitParams()[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS];
303-
304-
if (!$rootDirectory->getDriver() instanceof Filesystem\Driver\File) {
305-
$mediaPath = 'media';
306-
$varPath = 'media';
307-
} else {
308-
$mediaPath = $appParams[DirectoryList::MEDIA][DirectoryList::PATH];
309-
$varPath = $appParams[DirectoryList::VAR_DIR][DirectoryList::PATH];
310-
}
311-
$destDir = $rootDirectory->getRelativePath(
312-
$mediaPath . DIRECTORY_SEPARATOR . 'catalog' . DIRECTORY_SEPARATOR . 'product'
313-
);
314-
$tmpDir = $rootDirectory->getRelativePath(
315-
$varPath . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . 'images'
316-
);
317-
$rootDirectory->create($destDir);
318-
$rootDirectory->create($tmpDir);
319-
320305
$uploader = $this->_model->getUploader();
321306
$this->assertTrue($uploader->setDestDir($destDir));
322307
$this->assertTrue($uploader->setTmpDir($tmpDir));

0 commit comments

Comments
 (0)