From e98ceae1f49029ec5e9be1e9a98c1546ae2b8f8d Mon Sep 17 00:00:00 2001 From: Mark Beech Date: Wed, 9 Mar 2022 16:44:46 +0000 Subject: [PATCH] Add empty directory assertion (#41398) --- src/Illuminate/Filesystem/FilesystemAdapter.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 783ef3dc3a40..3e87c798abe7 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -148,6 +148,21 @@ public function assertMissing($path) return $this; } + /** + * Determine if a directory is empty. + * + * @param string $path + * @return $this + */ + public function assertDirectoryEmpty($path) + { + PHPUnit::assertEmpty( + $this->allFiles($path), "Directory [{$path}] is not empty." + ); + + return $this; + } + /** * Determine if a file or directory exists. *