Skip to content

Commit b66efca

Browse files
committed
B2B-2052: Image Uploader always uses full remote filesystem
1 parent 7e077c4 commit b66efca

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,41 @@ public function testUploadFileWithExcessiveFolderName(): void
8989
$uploader->save($longDirectoryFolderName);
9090
}
9191

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

0 commit comments

Comments
 (0)