Skip to content

Commit

Permalink
add: test for deleting a media
Browse files Browse the repository at this point in the history
  • Loading branch information
FarhanShares committed Mar 17, 2021
1 parent da30dc9 commit b9a329e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit b9a329e

Please sign in to comment.