You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 lines
1.6 KiB

<?php
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\Feature\Traits\FileTraits;
use Tests\TestCase;
class FileUpdateTest extends TestCase
{
use FileTraits;
// public function test_user_can_not_access_update_without_permission()
// {
// $this->assertFalse("it's not mohammad's fault, I'm waiting for dynamic policy");
// }
public function test_user_update_not_exits_files_not_found()
{
$data = [
"original_name" => 'original name is very bad',
"description" => 'this is a description for file and has beed updated',
];
$response = $this->loginAs()->putJson(route('api.files.update', ['collection_name' => 'not_exits', 'uuid' => app()->uuid, 'extention' => 'jpg']), $data);
$response->assertNotFound();
}
public function test_user_can_update_file()
{
$file = $this->one(File::class, dependencyAttributes: ['withImage' => true]);
$collection = Collection::find($file->collection_id);
$data = [
"original_name" => 'original name is very bad',
"description" => 'this is a description for file and has beed updated',
];
$response = $this->loginAs()->putJson(route('api.files.update', ['collection_name' => $collection->name, 'uuid' => $file->uuid, 'extention' => $collection->ext]), $data);
$response->assertok()->assertJson(['data' => $data]);
}
}