]> BookStack Code Mirror - bookstack/blobdiff - tests/EntityTest.php
Update PageRepo.php
[bookstack] / tests / EntityTest.php
index 07553e7dc26268825962ce8206add64218d3dee3..5bfedb53561952cde7d362e1d03e044e70cb926c 100644 (file)
@@ -5,7 +5,7 @@ use Illuminate\Support\Facades\DB;
 class EntityTest extends TestCase
 {
 
-    public function testEntityCreation()
+    public function test_entity_creation()
     {
 
         // Test Creation
@@ -51,7 +51,7 @@ class EntityTest extends TestCase
         return \BookStack\Book::find($book->id);
     }
 
-    public function testBookSortPageShows()
+    public function test_book_sort_page_shows()
     {
         $books =  \BookStack\Book::all();
         $bookToSort = $books[0];
@@ -65,7 +65,7 @@ class EntityTest extends TestCase
             ->see($books[1]->name);
     }
 
-    public function testBookSortItemReturnsBookContent()
+    public function test_book_sort_item_returns_book_content()
     {
         $books =  \BookStack\Book::all();
         $bookToSort = $books[0];
@@ -155,7 +155,7 @@ class EntityTest extends TestCase
         return $book;
     }
 
-    public function testPageSearch()
+    public function test_page_search()
     {
         $book = \BookStack\Book::all()->first();
         $page = $book->pages->first();
@@ -170,8 +170,49 @@ class EntityTest extends TestCase
             ->seePageIs($page->getUrl());
     }
 
+    public function test_invalid_page_search()
+    {
+        $this->asAdmin()
+            ->visit('/')
+            ->type('<p>test</p>', 'term')
+            ->press('header-search-box-button')
+            ->see('Search Results')
+            ->seeStatusCode(200);
+    }
+
+    public function test_empty_search_redirects_back()
+    {
+        $this->asAdmin()
+            ->visit('/')
+            ->visit('/search/all')
+            ->seePageIs('/');
+    }
+
+    public function test_book_search()
+    {
+        $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 test_empty_book_search_redirects_back()
+    {
+        $book = \BookStack\Book::all()->first();
+        $this->asAdmin()
+            ->visit('/books')
+            ->visit('/search/book/' . $book->id . '?term=')
+            ->seePageIs('/books');
+    }
+
 
-    public function testEntitiesViewableAfterCreatorDeletion()
+    public function test_entities_viewable_after_creator_deletion()
     {
         // Create required assets and revisions
         $creator = $this->getNewUser();
@@ -184,7 +225,7 @@ class EntityTest extends TestCase
         $this->checkEntitiesViewable($entities);
     }
 
-    public function testEntitiesViewableAfterUpdaterDeletion()
+    public function test_entities_viewable_after_updater_deletion()
     {
         // Create required assets and revisions
         $creator = $this->getNewUser();