Skip to content

Commit

Permalink
Merge pull request #5087 from driesvints/assert-exists-multiple-files
Browse files Browse the repository at this point in the history
[5.8] Document multiple file assertions when mocking
  • Loading branch information
taylorotwell authored Mar 26, 2019
2 parents fa93a5a + 93d7a51 commit 9646f0f
Showing 1 changed file with 11 additions and 8 deletions.
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

0 comments on commit 9646f0f

Please sign in to comment.