Skip to content

Commit 8f97fc5

Browse files
committed
Merge remote-tracking branch 'origin/B2B-2052' into B2B-2053
2 parents c424664 + b49131a commit 8f97fc5

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

dev/tests/integration/testsuite/Magento/Framework/File/MediaStorageUploaderTest.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Customer\Model\FileProcessor;
1111
use Magento\Framework\App\Filesystem\DirectoryList;
12+
use Magento\Framework\Filesystem\Driver\File;
1213

1314
/**
1415
* Test for \Magento\MediaStorage\Model\File\Uploader
@@ -89,6 +90,41 @@ public function testUploadFileWithExcessiveFolderName(): void
8990
$uploader->save($longDirectoryFolderName);
9091
}
9192

93+
/**
94+
* Upload file test to 'var' directory
95+
*
96+
* @magentoConfigFixture system/media_gallery/enabled 1
97+
* @magentoAppArea adminhtml
98+
*
99+
* @return void
100+
*/
101+
public function testUploadFileToVar(): void
102+
{
103+
$destinationDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
104+
$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
105+
106+
$fileName = 'file.txt';
107+
$destinationDir = 'tmp';
108+
$filePath = $tmpDirectory->getAbsolutePath($fileName);
109+
110+
$tmpDirectory->writeFile($fileName, 'some data');
111+
112+
$type = [
113+
'tmp_name' => $filePath,
114+
'name' => $fileName,
115+
];
116+
117+
$uploader = $this->uploaderFactory->create(['fileId' => $type]);
118+
$uploader->save($destinationDirectory->getAbsolutePath($destinationDir));
119+
120+
// Uploader doesn't save file to local var if remote storage is configured
121+
if ($this->filesystem->getDirectoryWrite(DirectoryList::MEDIA)->getDriver() instanceof File) {
122+
$this->assertTrue($destinationDirectory->isFile($destinationDir . DIRECTORY_SEPARATOR . $fileName));
123+
} else {
124+
$this->assertFalse($destinationDirectory->isFile($destinationDir . DIRECTORY_SEPARATOR . $fileName));
125+
}
126+
}
127+
92128
/**
93129
* Upload file test when `Old Media Gallery` is disabled
94130
*
@@ -130,7 +166,7 @@ public function dirCodeDataProvider(): array
130166
{
131167
return [
132168
'media destination' => [DirectoryList::MEDIA],
133-
'non-media destination' => [DirectoryList::VAR_DIR],
169+
'non-media destination' => [DirectoryList::VAR_IMPORT_EXPORT],
134170
];
135171
}
136172

0 commit comments

Comments
 (0)