@@ -146,7 +146,7 @@ public function deleteDirectory($path): void
146
146
*/
147
147
public function assertFileExists ($ filePath , $ message = '' ): void
148
148
{
149
- $ this ->assertTrue ($ this ->driver ->isExists ($ filePath ), $ message );
149
+ $ this ->assertTrue ($ this ->driver ->isExists ($ filePath ), " Failed asserting $ filePath exists. " . $ message );
150
150
}
151
151
152
152
/**
@@ -158,24 +158,38 @@ public function assertFileExists($filePath, $message = ''): void
158
158
*
159
159
* @throws \Magento\Framework\Exception\FileSystemException
160
160
*/
161
- public function assertGlobbedFileExists ($ path , $ pattern , $ message = "" ): void
161
+ public function assertGlobbedFileExists ($ path , $ pattern , $ message = '' ): void
162
162
{
163
163
$ 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 );
165
165
}
166
166
167
167
/**
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
169
169
*
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
171
185
* @param string $message
172
186
* @return void
173
187
*
174
188
* @throws \Magento\Framework\Exception\FileSystemException
175
189
*/
176
- public function assertFileDoesNotExist ( $ filePath , $ message = '' ): void
190
+ public function assertPathDoesNotExist ( $ path , $ message = '' ): void
177
191
{
178
- $ this ->assertFalse ($ this ->driver ->isExists ($ filePath ), $ message );
192
+ $ this ->assertFalse ($ this ->driver ->isExists ($ path ), " Failed asserting $ path does not exist. " . $ message );
179
193
}
180
194
181
195
/**
@@ -187,9 +201,9 @@ public function assertFileDoesNotExist($filePath, $message = ''): void
187
201
*
188
202
* @throws \Magento\Framework\Exception\FileSystemException
189
203
*/
190
- public function assertFileEmpty ($ filePath , $ message = "" ): void
204
+ public function assertFileEmpty ($ filePath , $ message = '' ): void
191
205
{
192
- $ this ->assertEmpty ($ this ->driver ->fileGetContents ($ filePath ), $ message );
206
+ $ this ->assertEmpty ($ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath is empty. " . $ message );
193
207
}
194
208
195
209
/**
@@ -201,9 +215,9 @@ public function assertFileEmpty($filePath, $message = ""): void
201
215
*
202
216
* @throws \Magento\Framework\Exception\FileSystemException
203
217
*/
204
- public function assertFileNotEmpty ($ filePath , $ message = "" ): void
218
+ public function assertFileNotEmpty ($ filePath , $ message = '' ): void
205
219
{
206
- $ this ->assertNotEmpty ($ this ->driver ->fileGetContents ($ filePath ), $ message );
220
+ $ this ->assertNotEmpty ($ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath is not empty. " . $ message );
207
221
}
208
222
209
223
/**
@@ -216,9 +230,9 @@ public function assertFileNotEmpty($filePath, $message = ""): void
216
230
*
217
231
* @throws \Magento\Framework\Exception\FileSystemException
218
232
*/
219
- public function assertFileContainsString ($ filePath , $ text , $ message = "" ): void
233
+ public function assertFileContainsString ($ filePath , $ text , $ message = '' ): void
220
234
{
221
- $ this ->assertStringContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), $ message );
235
+ $ this ->assertStringContainsString ($ text , $ this ->driver ->fileGetContents ($ filePath ), " Failed asserting $ filePath contains $ text . " . $ message );
222
236
}
223
237
224
238
/**
@@ -233,10 +247,10 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
233
247
*
234
248
* @throws \Magento\Framework\Exception\FileSystemException
235
249
*/
236
- public function assertGlobbedFileContainsString ($ path , $ pattern , $ text , $ fileIndex = 0 , $ message = "" ): void
250
+ public function assertGlobbedFileContainsString ($ path , $ pattern , $ text , $ fileIndex = 0 , $ message = '' ): void
237
251
{
238
252
$ 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 );
240
254
}
241
255
242
256
/**
@@ -264,9 +278,9 @@ public function assertFileDoesNotContainString($filePath, $text, $message = ""):
264
278
*
265
279
* @throws \Magento\Framework\Exception\FileSystemException
266
280
*/
267
- public function assertFileDoesNotContain ($ filePath , $ text , $ message = "" ): void
281
+ public function assertFileDoesNotContain ($ filePath , $ text , $ message = '' ): void
268
282
{
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 );
270
284
}
271
285
272
286
/**
@@ -278,8 +292,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
278
292
*
279
293
* @throws \Magento\Framework\Exception\FileSystemException
280
294
*/
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
282
310
{
283
- $ this ->assertEmpty ($ this ->driver ->readDirectory ($ path ), $ message );
311
+ $ this ->assertNotEmpty ($ this ->driver ->readDirectory ($ path ), " Failed asserting $ path is not empty. " . $ message );
284
312
}
285
313
}
0 commit comments