Browse Source

complete delete file

pull/2/head
Mohammad Khazaee 2 years ago
parent
commit
85efbc341f
  1. 39
      tests/Feature/FileDeleteTest.php
  2. 2
      tests/Feature/FileShowTest.php

39
tests/Feature/FileDeleteTest.php

@ -2,20 +2,45 @@
namespace Tests\Feature;
use App\Image\ImageProcessor;
use App\Models\Collection;
use App\Models\File;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class FileDeleteTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
public function test_user_with_permission_can_not_delete_file()
{
$this->assertTrue(true);
$this->assertFalse("it's not mohammad's fault, I'm waiting for dynamic policy");
}
public function test_user_with_permission_can_delete_file()
{
$collection = Collection::factory()->createQuietly([
'alt_required' => false,
'description_required' => false,
'tmp_support' => true,
'max_width' => 2000,
'max_height' => 2000,
'min_width' => 1,
'min_height' => 1,
'min_file_size' => 0
]);
$uuid = app()->uuid;
$file = File::factory()->createQuietly([
'uuid' => $uuid,
'server_path' => '/' . date('y') . '/' . date('m') . '/',
'user_id' => auth()->id(),
'collection_id' => $collection->id
]);
$imageProcessor = new ImageProcessor;
$imageProcessor->createFakeImage(storage_path('stub') . '/image.png', Storage::disk($collection->disk)->path($file->server_path . $uuid . '.' . $collection->ext));
$response = $this->loginAs()->deleteJson(route('api.files.destroy', ['collection_name' => $collection->name, 'uuid' => $file->uuid, 'extention' => $collection->ext]));
$response->assertok();
}
}

2
tests/Feature/FileShowTest.php

@ -13,7 +13,7 @@ class FileShowTest extends TestCase
*
* @return void
*/
public function test_example()
public function test_fake()
{
$this->assertTrue(true);
}

Loading…
Cancel
Save