Testing it can delete a non image file in root and subfolder

parent 00f3b8c6
......@@ -144,6 +144,35 @@ class ImagyTest extends MediaTestCase
$this->assertCount(0, $this->app['files']->allFiles($path));
}
/** @test */
public function it_can_delete_a_non_image_file()
{
$this->resetDatabase();
$file = \Illuminate\Http\UploadedFile::fake()->create('my-file.pdf');
$file = app(FileService::class)->store($file);
$this->assertCount(1, $this->app['files']->allFiles(public_path(config('asgard.media.config.files-path'))));
$this->imagy->deleteAllFor($file);
$this->assertCount(0, $this->app['files']->allFiles(public_path(config('asgard.media.config.files-path'))));
}
/** @test */
public function it_can_delete_a_non_image_file_on_subdirectory()
{
$this->resetDatabase();
app(FolderRepository::class)->create(['name' => 'My Folder', 'parent_id' => 0]);
$file = \Illuminate\Http\UploadedFile::fake()->create('my-file.pdf');
$file = app(FileService::class)->store($file, 1);
$path = public_path(config('asgard.media.config.files-path') . 'my-folder/');
$this->assertCount(1, $this->app['files']->allFiles($path));
$this->imagy->deleteAllFor($file);
$this->assertCount(0, $this->app['files']->allFiles($path));
}
/** @test */
public function it_should_return_same_path_for_non_images()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment