Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c87d319

Browse filesBrowse files
Add assertCount() for fake storage (#53620)
* Add assertCount() for fake storage * Update FilesystemAdapter.php * Update FilesystemAdapter.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent eb625fa commit c87d319
Copy full SHA for c87d319

File tree

Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed

‎src/Illuminate/Filesystem/FilesystemAdapter.php

Copy file name to clipboardExpand all lines: src/Illuminate/Filesystem/FilesystemAdapter.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,27 @@ public function assertExists($path, $content = null)
142142
return $this;
143143
}
144144

145+
/**
146+
* Assert that the number of files in path equals the expected count.
147+
*
148+
* @param string $path
149+
* @param int $count
150+
* @param bool $recursive
151+
* @return $this
152+
*/
153+
public function assertCount($path, $count, $recursive = false)
154+
{
155+
clearstatcache();
156+
157+
$actual = count($this->files($path, $recursive));
158+
159+
PHPUnit::assertEquals(
160+
$actual, $count, "Expected [{$count}] files at [{$path}], but found [{$actual}]."
161+
);
162+
163+
return $this;
164+
}
165+
145166
/**
146167
* Assert that the given file or directory does not exist.
147168
*

‎src/Illuminate/Support/Facades/Storage.php

Copy file name to clipboardExpand all lines: src/Illuminate/Support/Facades/Storage.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* @method static array allDirectories(string|null $directory = null)
4545
* @method static bool makeDirectory(string $path)
4646
* @method static bool deleteDirectory(string $directory)
47+
* @method static \Illuminate\Filesystem\FilesystemAdapter assertCount(string $path, int $count, bool $recursive)
4748
* @method static \Illuminate\Filesystem\FilesystemAdapter assertExists(string|array $path, string|null $content = null)
4849
* @method static \Illuminate\Filesystem\FilesystemAdapter assertMissing(string|array $path)
4950
* @method static \Illuminate\Filesystem\FilesystemAdapter assertDirectoryEmpty(string $path)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.