@@ -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 not 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 /**
@@ -264,9 +278,9 @@ public function assertFileDoesNotContainString($filePath, $text, $message = ""):
264278 *
265279 * @throws \Magento\Framework\Exception\FileSystemException
266280 */
267- public function assertFileDoesNotContain ($ filePath , $ text , $ message = "" ): void
281+ public function assertFileDoesNotContain ($ filePath , $ text , $ message = '' ): void
268282 {
269- $ this ->assertStringNotContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), $ message );
283+ $ this ->assertStringNotContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath does not contain $ text . " . $ message );
270284 }
271285
272286 /**
@@ -278,8 +292,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
278292 *
279293 * @throws \Magento\Framework\Exception\FileSystemException
280294 */
281- public function assertDirectoryEmpty ($ path , $ message = "" ): void
295+ public function assertDirectoryEmpty ($ path , $ message = '' ): void
296+ {
297+ $ this ->assertEmpty ($ this ->driver ->readDirectory ($ path ), "Failed asserting $ path is empty. " . $ message );
298+ }
299+
300+ /**
301+ * Asserts that a directory on the remote storage system is not empty
302+ *
303+ * @param string $path
304+ * @param string $message
305+ * @return void
306+ *
307+ * @throws \Magento\Framework\Exception\FileSystemException
308+ */
309+ public function assertDirectoryNotEmpty ($ path , $ message = '' ): void
282310 {
283- $ this ->assertEmpty ($ this ->driver ->readDirectory ($ path ), $ message );
311+ $ this ->assertNotEmpty ($ this ->driver ->readDirectory ($ path ), " Failed asserting $ path is not empty. " . $ message );
284312 }
285313}
0 commit comments