@@ -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 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
/**
@@ -249,9 +263,9 @@ public function assertGlobbedFileContainsString($path, $pattern, $text, $fileInd
249
263
*
250
264
* @throws \Magento\Framework\Exception\FileSystemException
251
265
*/
252
- public function assertFileDoesNotContain ($ filePath , $ text , $ message = "" ): void
266
+ public function assertFileDoesNotContain ($ filePath , $ text , $ message = '' ): void
253
267
{
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 );
255
269
}
256
270
257
271
/**
@@ -263,8 +277,22 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
263
277
*
264
278
* @throws \Magento\Framework\Exception\FileSystemException
265
279
*/
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
267
295
{
268
- $ this ->assertEmpty ($ this ->driver ->readDirectory ($ path ), $ message );
296
+ $ this ->assertNotEmpty ($ this ->driver ->readDirectory ($ path ), " Failed asserting $ path is not empty. " . $ message );
269
297
}
270
298
}
0 commit comments