@@ -107,6 +107,31 @@ public function testGetThumbsPath(): void
107
107
);
108
108
}
109
109
110
+ /**
111
+ * @return void
112
+ */
113
+ public function testDeleteDirectory (): void
114
+ {
115
+ $ path = $ this ->objectManager ->get (\Magento \Cms \Helper \Wysiwyg \Images::class)->getCurrentPath ();
116
+ $ dir = 'testDeleteDirectory ' ;
117
+ $ fullPath = $ path . $ dir ;
118
+ $ this ->storage ->createDirectory ($ dir , $ path );
119
+ $ this ->assertFileExists ($ fullPath );
120
+ $ this ->storage ->deleteDirectory ($ fullPath );
121
+ $ this ->assertFileNotExists ($ fullPath );
122
+ }
123
+
124
+ /**
125
+ * @return void
126
+ * @expectedException \Magento\Framework\Exception\LocalizedException
127
+ * @expectedExceptionMessage We cannot delete directory /downloadable.
128
+ */
129
+ public function testDeleteDirectoryWithExcludedDirPath (): void
130
+ {
131
+ $ dir = $ this ->objectManager ->get (\Magento \Cms \Helper \Wysiwyg \Images::class)->getCurrentPath () . 'downloadable ' ;
132
+ $ this ->storage ->deleteDirectory ($ dir );
133
+ }
134
+
110
135
/**
111
136
* @return void
112
137
*/
@@ -126,11 +151,39 @@ public function testUploadFile(): void
126
151
'error ' => 0 ,
127
152
'size ' => 12500 ,
128
153
];
154
+
129
155
$ this ->storage ->uploadFile (self ::$ _baseDir );
130
156
$ this ->assertTrue (is_file (self ::$ _baseDir . DIRECTORY_SEPARATOR . $ fileName ));
131
157
// phpcs:enable
132
158
}
133
159
160
+ /**
161
+ * @return void
162
+ * @expectedException \Magento\Framework\Exception\LocalizedException
163
+ * @expectedExceptionMessage We can't upload the file to current folder right now. Please try another folder.
164
+ */
165
+ public function testUploadFileWithExcludedDirPath (): void
166
+ {
167
+ $ fileName = 'magento_small_image.jpg ' ;
168
+ $ tmpDirectory = $ this ->filesystem ->getDirectoryWrite (\Magento \Framework \App \Filesystem \DirectoryList::SYS_TMP );
169
+ $ filePath = $ tmpDirectory ->getAbsolutePath ($ fileName );
170
+ // phpcs:disable
171
+ $ fixtureDir = realpath (__DIR__ . '/../../../../Catalog/_files ' );
172
+ copy ($ fixtureDir . DIRECTORY_SEPARATOR . $ fileName , $ filePath );
173
+
174
+ $ _FILES ['image ' ] = [
175
+ 'name ' => $ fileName ,
176
+ 'type ' => 'image/jpeg ' ,
177
+ 'tmp_name ' => $ filePath ,
178
+ 'error ' => 0 ,
179
+ 'size ' => 12500 ,
180
+ ];
181
+
182
+ $ dir = $ this ->objectManager ->get (\Magento \Cms \Helper \Wysiwyg \Images::class)->getCurrentPath () . 'downloadable ' ;
183
+ $ this ->storage ->uploadFile ($ dir );
184
+ // phpcs:enable
185
+ }
186
+
134
187
/**
135
188
* @param string $fileName
136
189
* @param string $fileType
0 commit comments