@@ -146,7 +146,7 @@ public function deleteDirectory($path): void
146146 */
147147 public function assertFileExists ($ filePath , $ message = '' ): void
148148 {
149- $ this ->assertTrue ($ this ->driver ->isExists ($ filePath ), $ message );
149+ $ this ->assertTrue ($ this ->driver ->isExists ($ filePath ), " Failed asserting $ filePath exists. " . $ message );
150150 }
151151
152152 /**
@@ -158,24 +158,38 @@ public function assertFileExists($filePath, $message = ''): void
158158 *
159159 * @throws \Magento\Framework\Exception\FileSystemException
160160 */
161- public function assertGlobbedFileExists ($ path , $ pattern , $ message = "" ): void
161+ public function assertGlobbedFileExists ($ path , $ pattern , $ message = '' ): void
162162 {
163163 $ files = $ this ->driver ->search ($ pattern , $ path );
164- $ this ->assertNotEmpty ($ files , $ message );
164+ $ this ->assertNotEmpty ($ files , " Failed asserting file matching glob pattern \" $ pattern \" at location \" $ path \" is not empty. " . $ message );
165165 }
166166
167167 /**
168- * Assert a file does not exist on the remote storage system
168+ * Asserts that a file or directory exists on the remote storage system
169169 *
170- * @param string $filePath
170+ * @param string $path
171+ * @param string $message
172+ * @return void
173+ *
174+ * @throws \Magento\Framework\Exception\FileSystemException
175+ */
176+ public function assertPathExists ($ path , $ message = '' ): void
177+ {
178+ $ this ->assertTrue ($ this ->driver ->isExists ($ path ), "Failed asserting $ path exists. " . $ message );
179+ }
180+
181+ /**
182+ * Asserts that a file or directory does not exist on the remote storage system
183+ *
184+ * @param string $path
171185 * @param string $message
172186 * @return void
173187 *
174188 * @throws \Magento\Framework\Exception\FileSystemException
175189 */
176- public function assertFileDoesNotExist ( $ filePath , $ message = '' ): void
190+ public function assertPathDoesNotExist ( $ path , $ message = '' ): void
177191 {
178- $ this ->assertFalse ($ this ->driver ->isExists ($ filePath ), $ message );
192+ $ this ->assertFalse ($ this ->driver ->isExists ($ path ), " Failed asserting $ path does not exist. " . $ message );
179193 }
180194
181195 /**
@@ -187,9 +201,9 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
187201 *
188202 * @throws \Magento\Framework\Exception\FileSystemException
189203 */
190- public function assertFileEmpty ($ filePath , $ message = "" ): void
204+ public function assertFileEmpty ($ filePath , $ message = '' ): void
191205 {
192- $ this ->assertEmpty ($ this ->driver ->fileGetContents ($ filePath ), $ message );
206+ $ this ->assertEmpty ($ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath is empty. " . $ message );
193207 }
194208
195209 /**
@@ -201,9 +215,9 @@ public function assertFileEmpty($filePath, $message = ""): void
201215 *
202216 * @throws \Magento\Framework\Exception\FileSystemException
203217 */
204- public function assertFileNotEmpty ($ filePath , $ message = "" ): void
218+ public function assertFileNotEmpty ($ filePath , $ message = '' ): void
205219 {
206- $ this ->assertNotEmpty ($ this ->driver ->fileGetContents ($ filePath ), $ message );
220+ $ this ->assertNotEmpty ($ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath is empty. " . $ message );
207221 }
208222
209223 /**
@@ -216,9 +230,9 @@ public function assertFileNotEmpty($filePath, $message = ""): void
216230 *
217231 * @throws \Magento\Framework\Exception\FileSystemException
218232 */
219- public function assertFileContainsString ($ filePath , $ text , $ message = "" ): void
233+ public function assertFileContainsString ($ filePath , $ text , $ message = '' ): void
220234 {
221- $ this ->assertStringContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), $ message );
235+ $ this ->assertStringContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath contains $ text . " . $ message );
222236 }
223237
224238 /**
@@ -233,10 +247,10 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
233247 *
234248 * @throws \Magento\Framework\Exception\FileSystemException
235249 */
236- public function assertGlobbedFileContainsString ($ path , $ pattern , $ text , $ fileIndex = 0 , $ message = "" ): void
250+ public function assertGlobbedFileContainsString ($ path , $ pattern , $ text , $ fileIndex = 0 , $ message = '' ): void
237251 {
238252 $ files = $ this ->driver ->search ($ pattern , $ path );
239- $ this ->assertStringContainsString ($ text , $ this ->driver ->fileGetContents ($ files [$ fileIndex ] ?? '' ), $ message );
253+ $ this ->assertStringContainsString ($ text , $ this ->driver ->fileGetContents ($ files [$ fileIndex ] ?? '' ), " Failed asserting file of index \" $ fileIndex \" matching glob pattern \" $ pattern \" at location \" $ path \" contains $ text . " . $ message );
240254 }
241255
242256 /**
@@ -249,9 +263,9 @@ public function assertGlobbedFileContainsString($path, $pattern, $text, $fileInd
249263 *
250264 * @throws \Magento\Framework\Exception\FileSystemException
251265 */
252- public function assertFileDoesNotContain ($ filePath , $ text , $ message = "" ): void
266+ public function assertFileDoesNotContain ($ filePath , $ text , $ message = '' ): void
253267 {
254- $ this ->assertStringNotContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), $ message );
268+ $ this ->assertStringNotContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath does not contain $ text . " . $ message );
255269 }
256270
257271 /**
@@ -263,8 +277,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
263277 *
264278 * @throws \Magento\Framework\Exception\FileSystemException
265279 */
266- public function assertDirectoryEmpty ($ path , $ message = "" ): void
280+ public function assertDirectoryEmpty ($ path , $ message = '' ): void
281+ {
282+ $ this ->assertEmpty ($ this ->driver ->readDirectory ($ path ), "Failed asserting $ path is empty. " . $ message );
283+ }
284+
285+ /**
286+ * Asserts that a directory on the remote storage system is not empty
287+ *
288+ * @param string $path
289+ * @param string $message
290+ * @return void
291+ *
292+ * @throws \Magento\Framework\Exception\FileSystemException
293+ */
294+ public function assertDirectoryNotEmpty ($ path , $ message = '' ): void
267295 {
268- $ this ->assertEmpty ($ this ->driver ->readDirectory ($ path ), $ message );
296+ $ this ->assertNotEmpty ($ this ->driver ->readDirectory ($ path ), " Failed asserting $ path is not empty. " . $ message );
269297 }
270298}
0 commit comments