Skip to content

Commit fb11d8b

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

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function setUp(): void
5151
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
5252
$this->sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName;
5353
//Refers to tests 'var' directory
54-
$this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT);
54+
$this->varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
5555
}
5656

5757
/**
@@ -84,12 +84,16 @@ public function testExecute($file): void
8484
*
8585
* @param $destinationFilePath
8686
* @return void
87+
* @throws \Magento\Framework\Exception\FileSystemException
8788
*/
8889
protected function copyFile($destinationFilePath): void
8990
{
90-
//Refers to application root directory
91-
$rootDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::ROOT);
92-
$rootDirectory->copyFile($this->sourceFilePath, $this->varDirectory->getAbsolutePath($destinationFilePath));
91+
$driver = $this->varDirectory->getDriver();
92+
93+
$driver->filePutContents(
94+
$this->varDirectory->getAbsolutePath($destinationFilePath),
95+
file_get_contents($this->sourceFilePath)
96+
);
9397
}
9498

9599
/**
@@ -112,7 +116,7 @@ public static function tearDownAfterClass(): void
112116
{
113117
$filesystem = Bootstrap::getObjectManager()->get(Filesystem::class);
114118
/** @var WriteInterface $directory */
115-
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
119+
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
116120
if ($directory->isExist('export')) {
117121
$directory->delete('export');
118122
}

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

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

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

61-
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
62-
$auth = $this->_objectManager->get(Auth::class);
63-
$auth->getAuthStorage()->setIsFirstPageAfterLogin(false);
61+
$this->auth = $this->_objectManager->get(Auth::class);
62+
$this->auth->getAuthStorage()->setIsFirstPageAfterLogin(false);
6463
$this->backendUrl = $this->_objectManager->get(BackendUrl::class);
6564
$this->backendUrl->turnOnSecretKey();
6665
$this->sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName;
66+
67+
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
6768
//Refers to tests 'var' directory
68-
$this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR);
69+
$this->varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
6970
}
7071

7172
/**
@@ -121,12 +122,16 @@ public function testExecute($file): void
121122
*
122123
* @param $destinationFilePath
123124
* @return void
125+
* @throws \Magento\Framework\Exception\FileSystemException
124126
*/
125127
private function copyFile($destinationFilePath): void
126128
{
127-
//Refers to application root directory
128-
$rootDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::ROOT);
129-
$rootDirectory->copyFile($this->sourceFilePath, $this->varDirectory->getAbsolutePath($destinationFilePath));
129+
$driver = $this->varDirectory->getDriver();
130+
131+
$driver->filePutContents(
132+
$this->varDirectory->getAbsolutePath($destinationFilePath),
133+
file_get_contents($this->sourceFilePath)
134+
);
130135
}
131136

132137
/**
@@ -159,7 +164,7 @@ public static function tearDownAfterClass(): void
159164
{
160165
$filesystem = Bootstrap::getObjectManager()->get(Filesystem::class);
161166
/** @var WriteInterface $directory */
162-
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
167+
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
163168
if ($directory->isExist('export')) {
164169
$directory->delete('export');
165170
}

0 commit comments

Comments
 (0)