]> BookStack Code Mirror - bookstack/blobdiff - tests/EntityTest.php
Added more tests to increase test coverage
[bookstack] / tests / EntityTest.php
index 4c4195fd9fd0ecfcee09876a586af57fc7b8f18d..1eda7c73c2775e52dff5d0781e676dc3c373abc4 100644 (file)
@@ -188,6 +188,29 @@ class EntityTest extends TestCase
             ->seePageIs('/');
     }
 
+    public function testBookSearch()
+    {
+        $book = \BookStack\Book::all()->first();
+        $page = $book->pages->last();
+        $chapter = $book->chapters->last();
+
+        $this->asAdmin()
+            ->visit('/search/book/' . $book->id . '?term=' . urlencode($page->name))
+            ->see($page->name)
+
+            ->visit('/search/book/' . $book->id  . '?term=' . urlencode($chapter->name))
+            ->see($chapter->name);
+    }
+
+    public function testEmptyBookSearchRedirectsBack()
+    {
+        $book = \BookStack\Book::all()->first();
+        $this->asAdmin()
+            ->visit('/books')
+            ->visit('/search/book/' . $book->id . '?term=')
+            ->seePageIs('/books');
+    }
+
 
     public function testEntitiesViewableAfterCreatorDeletion()
     {