]> BookStack Code Mirror - bookstack/commitdiff
Test for cover image.
authorNilesh Deepak <redacted>
Sat, 15 Jul 2017 13:06:49 +0000 (18:36 +0530)
committerNilesh Deepak <redacted>
Sat, 15 Jul 2017 13:06:49 +0000 (18:36 +0530)
tests/Entity/EntityTest.php
tests/ImageTest.php

index 180b302c6d299bb16a84ea3f2b5c7d7cc7cf9159..b818fcc38cf16934d66a3d170126471fbdcb7c9d 100644 (file)
@@ -5,7 +5,6 @@ use BookStack\Chapter;
 use BookStack\Page;
 use BookStack\Repos\EntityRepo;
 use BookStack\Repos\UserRepo;
-use ImageTest;
 
 class EntityTest extends BrowserKitTest
 {
@@ -138,7 +137,8 @@ class EntityTest extends BrowserKitTest
         $book = factory(Book::class)->make([
             'name' => 'My First Book'
         ]);
-        $imagePath = uploadImage('test-image.jpg', 0);
+
+        $this->uploadImage('test-image.jpg', 0);
         $this->asAdmin()
             ->visit('/books')
             // Choose to create a book
@@ -277,4 +277,20 @@ class EntityTest extends BrowserKitTest
             ->seeInElement('#recently-created-pages', $entityChain['page']->name);
     }
 
+    protected function uploadImage($name, $uploadedTo = 0)
+    {
+        $file = $this->getTestImage($name);
+        $this->call('POST', '/images/gallery/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
+        return $this->getTestImagePath('gallery', $name);
+    }
+
+    protected function getTestImage($fileName)
+    {
+        return new \Illuminate\Http\UploadedFile(base_path('tests/test-data/test-image.jpg'), $fileName, 'image/jpeg', 5238);
+    }
+
+    protected function getTestImagePath($type, $fileName)
+    {
+        return '/uploads/images/' . $type . '/' . Date('Y-m-M') . '/' . $fileName;
+    }
 }
index 898972f7def5b92767e24c248248d5457861c6fc..3bb41138bae7d50dd8d9821fed27bf0ad54ebad0 100644 (file)
@@ -30,7 +30,7 @@ class ImageTest extends BrowserKitTest
      * @param int $uploadedTo
      * @return string
      */
-    public function uploadImage($name, $uploadedTo = 0)
+    protected function uploadImage($name, $uploadedTo = 0)
     {
         $file = $this->getTestImage($name);
         $this->call('POST', '/images/gallery/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
Morty Proxy This is a proxified and sanitized view of the page, visit original site.