From b9a329e891550f57cd22f736dda19919f0cf72bd Mon Sep 17 00:00:00 2001 From: Farhan Israq Date: Wed, 17 Mar 2021 23:13:19 +0600 Subject: [PATCH] add: test for deleting a media --- tests/MediaTest.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/MediaTest.php b/tests/MediaTest.php index b2ab0ed..040bd26 100644 --- a/tests/MediaTest.php +++ b/tests/MediaTest.php @@ -6,6 +6,7 @@ use Mockery; use Illuminate\Filesystem\Filesystem; use FarhanShares\MediaMan\Models\Media; +use Illuminate\Support\Facades\Storage; use FarhanShares\MediaMan\MediaUploader; use FarhanShares\MediaMan\Tests\TestCase; use Illuminate\Database\Eloquent\Collection as ElCollection; @@ -67,7 +68,17 @@ public function it_can_update_a_media_record() /** @test */ public function it_can_delete_a_media_record() { - // pivot should be deleted as well + $media = MediaUploader::source($this->fileOne) + ->useName('image') + ->useDisk('default') + ->upload(); + + $mediaId = $media->id; + $mediaFile = $media->file_name; + $media->delete(); + + $this->assertEquals(null, Media::find($mediaId)); + $this->assertEquals(false, Storage::disk('default')->exists($mediaFile)); } /** @test */