Skip to content

Commit bf0f269

Browse files
committed
B2B-2017: [AWS S3] [Integration Tests]: Investigate Test Failures in ImportExport module
1 parent d58924b commit bf0f269

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function execute()
7171
$resultRedirect = $this->resultRedirectFactory->create();
7272
$resultRedirect->setPath('adminhtml/export/index');
7373
$fileName = $this->getRequest()->getParam('filename');
74-
$exportDirectory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT);
74+
$exportDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
7575

7676
try {
7777
$fileExist = $exportDirectory->isExist('export/' . $fileName);
@@ -87,8 +87,7 @@ public function execute()
8787

8888
try {
8989
$path = 'export/' . $fileName;
90-
$directory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT);
91-
if ($directory->isFile($path)) {
90+
if ($exportDirectory->isFile($path)) {
9291
return $this->fileFactory->create(
9392
$this->localizedFileName->getFileDisplayName($path),
9493
['type' => 'filename', 'value' => $path],

dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ public function testExecute($file): void
8989
protected function copyFile($destinationFilePath): void
9090
{
9191
$driver = $this->varDirectory->getDriver();
92+
$absolutePath = $this->varDirectory->getAbsolutePath($destinationFilePath);
9293

93-
$driver->filePutContents(
94-
$this->varDirectory->getAbsolutePath($destinationFilePath),
95-
file_get_contents($this->sourceFilePath)
96-
);
94+
$driver->createDirectory(dirname($absolutePath));
95+
$driver->filePutContents($absolutePath, file_get_contents($this->sourceFilePath));
9796
}
9897

9998
/**

dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DownloadTest extends AbstractBackendController
4949
/**
5050
* @var string
5151
*/
52-
private string $sourceFilePath;
52+
private $sourceFilePath;
5353

5454
/**
5555
* @inheritdoc
@@ -58,13 +58,12 @@ protected function setUp(): void
5858
{
5959
parent::setUp();
6060

61+
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
6162
$this->auth = $this->_objectManager->get(Auth::class);
6263
$this->auth->getAuthStorage()->setIsFirstPageAfterLogin(false);
6364
$this->backendUrl = $this->_objectManager->get(BackendUrl::class);
6465
$this->backendUrl->turnOnSecretKey();
6566
$this->sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName;
66-
67-
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
6867
//Refers to tests 'var' directory
6968
$this->varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
7069
}
@@ -122,16 +121,14 @@ public function testExecute($file): void
122121
*
123122
* @param $destinationFilePath
124123
* @return void
125-
* @throws \Magento\Framework\Exception\FileSystemException
126124
*/
127125
private function copyFile($destinationFilePath): void
128126
{
129127
$driver = $this->varDirectory->getDriver();
128+
$absolutePath = $this->varDirectory->getAbsolutePath($destinationFilePath);
130129

131-
$driver->filePutContents(
132-
$this->varDirectory->getAbsolutePath($destinationFilePath),
133-
file_get_contents($this->sourceFilePath)
134-
);
130+
$driver->createDirectory(dirname($absolutePath));
131+
$driver->filePutContents($absolutePath, file_get_contents($this->sourceFilePath));
135132
}
136133

137134
/**

0 commit comments

Comments
 (0)