Skip to content

Commit 04400b0

Browse files
add integration test
1 parent 011a443 commit 04400b0

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,51 @@ public function testUploadFileFromNotAllowedFolder(): void
8585
$this->uploaderFactory->create(['fileId' => $type]);
8686
}
8787

88+
/**
89+
* Upload file test when `Old Media Gallery` is disabled
90+
*
91+
* @magentoConfigFixture system/media_gallery/enabled 1
92+
* @magentoAppArea adminhtml
93+
* @dataProvider dirCodeDataProvider
94+
*
95+
* @param string $directoryCode
96+
* @return void
97+
*/
98+
public function testUploadFileWhenOldMediaGalleryDisabled(string $directoryCode): void
99+
{
100+
$destinationDirectory = $this->filesystem->getDirectoryWrite($directoryCode);
101+
$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
102+
103+
$fileName = 'file.txt';
104+
$destinationDir = 'tmp';
105+
$filePath = $tmpDirectory->getAbsolutePath($fileName);
106+
107+
$tmpDirectory->writeFile($fileName, 'some data');
108+
109+
$type = [
110+
'tmp_name' => $filePath,
111+
'name' => $fileName,
112+
];
113+
114+
$uploader = $this->uploaderFactory->create(['fileId' => $type]);
115+
$uploader->save($destinationDirectory->getAbsolutePath($destinationDir));
116+
117+
$this->assertTrue($destinationDirectory->isFile($destinationDir . DIRECTORY_SEPARATOR . $fileName));
118+
}
119+
120+
/**
121+
* DataProvider for testUploadFileWhenOldMediaGalleryDisabled
122+
*
123+
* @return array
124+
*/
125+
public function dirCodeDataProvider(): array
126+
{
127+
return [
128+
'media destination' => [DirectoryList::MEDIA],
129+
'non-media destination' => [DirectoryList::VAR_DIR],
130+
];
131+
}
132+
88133
/**
89134
* @inheritdoc
90135
*/

0 commit comments

Comments
 (0)