Skip to content

Commit 97540cd

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

File tree

3 files changed

+13
-21
lines changed
  • app/code/Magento
  • dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File

3 files changed

+13
-21
lines changed

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

Lines changed: 3 additions & 2 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->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
74+
$exportDirectory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT);
7575

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

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

app/code/Magento/RemoteStorage/etc/di.xml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,14 @@
1111
<preference for="Magento\RemoteStorage\Driver\Adapter\MetadataProviderInterface" type="Magento\RemoteStorage\Driver\Adapter\MetadataProvider"/>
1212
<preference for="Magento\RemoteStorage\Driver\Adapter\MetadataProviderFactoryInterface" type="Magento\RemoteStorage\Driver\Adapter\MetadataProviderFactory"/>
1313
<preference for="Magento\Framework\Filesystem\DriverPool" type="Magento\RemoteStorage\Driver\DriverPool"/>
14-
<virtualType name="remoteWriteFactory" type="Magento\Framework\Filesystem\Directory\WriteFactory">
15-
<arguments>
16-
<argument name="driverPool" xsi:type="object">Magento\RemoteStorage\Driver\DriverPool</argument>
17-
</arguments>
18-
</virtualType>
19-
<virtualType name="remoteReadFactory" type="Magento\Framework\Filesystem\Directory\ReadFactory">
20-
<arguments>
21-
<argument name="driverPool" xsi:type="object">Magento\RemoteStorage\Driver\DriverPool</argument>
22-
</arguments>
23-
</virtualType>
2414
<type name="Magento\RemoteStorage\Filesystem">
2515
<arguments>
2616
<argument name="writeFactory" xsi:type="object">
2717
Magento\RemoteStorage\Model\Filesystem\Directory\WriteFactory
2818
</argument>
19+
<argument name="readFactory" xsi:type="object">
20+
Magento\RemoteStorage\Model\Filesystem\Directory\ReaderFactory
21+
</argument>
2922
</arguments>
3023
</type>
3124
<virtualType name="customRemoteFilesystem" type="Magento\RemoteStorage\Filesystem">

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ protected function setUp(): void
5959
parent::setUp();
6060

6161
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
62-
$this->auth = $this->_objectManager->get(Auth::class);
63-
$this->auth->getAuthStorage()->setIsFirstPageAfterLogin(false);
62+
$auth = $this->_objectManager->get(Auth::class);
63+
$auth->getAuthStorage()->setIsFirstPageAfterLogin(false);
6464
$this->backendUrl = $this->_objectManager->get(BackendUrl::class);
6565
$this->backendUrl->turnOnSecretKey();
6666
$this->sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName;
6767
//Refers to tests 'var' directory
68-
$this->varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
68+
$this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR);
6969
}
7070

7171
/**
@@ -124,11 +124,9 @@ public function testExecute($file): void
124124
*/
125125
private function copyFile($destinationFilePath): void
126126
{
127-
$driver = $this->varDirectory->getDriver();
128-
$absolutePath = $this->varDirectory->getAbsolutePath($destinationFilePath);
129-
130-
$driver->createDirectory(dirname($absolutePath));
131-
$driver->filePutContents($absolutePath, file_get_contents($this->sourceFilePath));
127+
//Refers to application root directory
128+
$rootDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::ROOT);
129+
$rootDirectory->copyFile($this->sourceFilePath, $this->varDirectory->getAbsolutePath($destinationFilePath));
132130
}
133131

134132
/**
@@ -161,7 +159,7 @@ public static function tearDownAfterClass(): void
161159
{
162160
$filesystem = Bootstrap::getObjectManager()->get(Filesystem::class);
163161
/** @var WriteInterface $directory */
164-
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
162+
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
165163
if ($directory->isExist('export')) {
166164
$directory->delete('export');
167165
}

0 commit comments

Comments
 (0)