From 4bea40213a994e727865526cb4f3efb5164574bf Mon Sep 17 00:00:00 2001 From: Mark Beech Date: Tue, 8 Mar 2022 22:16:49 +0000 Subject: [PATCH] Add empty directory assertion --- 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. *