]> BookStack Code Mirror - bookstack/blobdiff - tests/ImageTest.php
Added 'zh_CN' to app.locales
[bookstack] / tests / ImageTest.php
index c75617c0e1578e0e5f8cbd6e0837cd10251b45dd..881f73b552a93e2b4298774533bbc3672d44914f 100644 (file)
@@ -184,4 +184,28 @@ class ImageTest extends TestCase
         $this->assertTrue($testImageData === $uploadedImageData, "Uploaded image file data does not match our test image as expected");
     }
 
+    public function test_user_images_deleted_on_user_deletion()
+    {
+        $editor = $this->getEditor();
+        $this->actingAs($editor);
+
+        $imageName = 'profile.png';
+        $relPath = $this->getTestImagePath('gallery', $imageName);
+        $this->deleteImage($relPath);
+
+        $file = $this->getTestImage($imageName);
+        $this->call('POST', '/images/user/upload', [], [], ['file' => $file], []);
+        $this->call('POST', '/images/user/upload', [], [], ['file' => $file], []);
+
+        $profileImages = Image::where('type', '=', 'user')->where('created_by', '=', $editor->id)->get();
+        $this->assertTrue($profileImages->count() === 2, "Found profile images does not match upload count");
+
+        $userDelete = $this->asAdmin()->delete("/settings/users/{$editor->id}");
+        $userDelete->assertStatus(302);
+        $this->assertDatabaseMissing('images', [
+            'type' => 'user',
+            'created_by' => $editor->id
+        ]);
+    }
+
 }
\ No newline at end of file