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(); } // /** // * @dataProvider updateValidationTestProvider // */ // public function test_user_send_unproccable_fileds($collectionFields, $dataFields) // { // $collection = Collection::factory()->create($collectionFields); // $uuid = app()->uuid; // $file = File::factory()->createQuietly([ // 'uuid' => $uuid, // 'server_path' => '/' . date('y') . '/' . date('m') . '/', // 'user_id' => auth()->id(), // 'collection_id' => $collection->id // ]); // $response = $this->loginAs()->postJson(route('api.files.update', ['collection_name' => $collection->name, 'uuid' => $file->uuid, 'ext' => $collection->ext]), $dataFields); // $response->assertUnprocessable(); // } public function test_user_can_update_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)); $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]); } }