@@ -85,6 +85,51 @@ public function testUploadFileFromNotAllowedFolder(): void
85
85
$ this ->uploaderFactory ->create (['fileId ' => $ type ]);
86
86
}
87
87
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
+
88
133
/**
89
134
* @inheritdoc
90
135
*/
0 commit comments