X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c81cb6f2afd79c33104671ea31f4b0a0e9f85eba..3f5dc10cd4cf901b44b1cf8c9e2626bf0425d488:/tests/Api/ImageGalleryApiTest.php diff --git a/tests/Api/ImageGalleryApiTest.php b/tests/Api/ImageGalleryApiTest.php index 17c90518c..067173a6b 100644 --- a/tests/Api/ImageGalleryApiTest.php +++ b/tests/Api/ImageGalleryApiTest.php @@ -295,7 +295,24 @@ class ImageGalleryApiTest extends TestCase ]); } - public function test_update_endpoint_requires_image_delete_permission() + public function test_update_existing_image_file() + { + $this->actingAsApiAdmin(); + $imagePage = $this->entities->page(); + $data = $this->files->uploadGalleryImageToPage($this, $imagePage); + $image = Image::findOrFail($data['response']->id); + + $this->assertFileEquals($this->files->testFilePath('test-image.png'), public_path($data['path'])); + + $resp = $this->call('PUT', $this->baseEndpoint . "/{$image->id}", [], [], [ + 'image' => $this->files->uploadedImage('my-cool-image.png', 'compressed.png'), + ]); + + $resp->assertStatus(200); + $this->assertFileEquals($this->files->testFilePath('compressed.png'), public_path($data['path'])); + } + + public function test_update_endpoint_requires_image_update_permission() { $user = $this->users->editor(); $this->actingAsForApi($user);