]> BookStack Code Mirror - bookstack/blobdiff - tests/ImageTest.php
Updated version for v0.15.3
[bookstack] / tests / ImageTest.php
index 806a36acc11fcb507987ba4e9ab2fc6935afa2fd..3bb41138bae7d50dd8d9821fed27bf0ad54ebad0 100644 (file)
@@ -1,6 +1,6 @@
-<?php
+<?php namespace Tests;
 
-class ImageTest extends TestCase
+class ImageTest extends BrowserKitTest
 {
 
     /**
@@ -10,7 +10,7 @@ class ImageTest extends TestCase
      */
     protected function getTestImage($fileName)
     {
-        return new \Illuminate\Http\UploadedFile(base_path('tests/test-image.jpg'), $fileName, 'image/jpeg', 5238);
+        return new \Illuminate\Http\UploadedFile(base_path('tests/test-data/test-image.jpg'), $fileName, 'image/jpeg', 5238);
     }
 
     /**
@@ -57,10 +57,12 @@ class ImageTest extends TestCase
         $relPath = $this->uploadImage($imageName, $page->id);
         $this->assertResponseOk();
 
-        $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image exists');
+        $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image not found at path: '. public_path($relPath));
+
+        $this->deleteImage($relPath);
 
         $this->seeInDatabase('images', [
-            'url' => $relPath,
+            'url' => $this->baseUrl . $relPath,
             'type' => 'gallery',
             'uploaded_to' => $page->id,
             'path' => $relPath,
@@ -68,8 +70,7 @@ class ImageTest extends TestCase
             'updated_by' => $admin->id,
             'name' => $imageName
         ]);
-        
-        $this->deleteImage($relPath);
+
     }
 
     public function test_image_delete()
@@ -85,11 +86,11 @@ class ImageTest extends TestCase
         $this->assertResponseOk();
 
         $this->dontSeeInDatabase('images', [
-            'url' => $relPath,
+            'url' => $this->baseUrl . $relPath,
             'type' => 'gallery'
         ]);
 
-        $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has been deleted');
+        $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has not been deleted as expected');
     }
 
 }
\ No newline at end of file