Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Document multiple file assertions when mocking #5087

Merged
merged 2 commits into from
Mar 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,22 @@ The `Storage` facade's `fake` method allows you to easily generate a fake disk t

class ExampleTest extends TestCase
{
public function testAvatarUpload()
public function testAlbumUpload()
{
Storage::fake('avatars');
Storage::fake('photos');

$response = $this->json('POST', '/avatar', [
'avatar' => UploadedFile::fake()->image('avatar.jpg')
$response = $this->json('POST', '/photos', [
UploadedFile::fake()->image('photo1.jpg'),
UploadedFile::fake()->image('photo2.jpg')
]);

// Assert the file was stored...
Storage::disk('avatars')->assertExists('avatar.jpg');
// Assert one or more files were stored...
Storage::disk('photos')->assertExists('photo1.jpg');
Storage::disk('photos')->assertExists(['photo1.jpg', 'photo2.jpg']);

// Assert a file does not exist...
Storage::disk('avatars')->assertMissing('missing.jpg');
// Assert one or more files were not stored...
Storage::disk('photos')->assertMissing('missing.jpg');
Storage::disk('photos')->assertMissing(['missing.jpg', 'non-existing.jpg']);
}
}

Expand Down