]> BookStack Code Mirror - bookstack/blob - tests/Entity/EntitySearchTest.php
Making sure MyISAM is set for the tables that need it for new installtions that are...
[bookstack] / tests / Entity / EntitySearchTest.php
1 <?php
2
3 use Illuminate\Support\Facades\DB;
4
5 class EntitySearchTest extends TestCase
6 {
7
8     public function test_page_search()
9     {
10         $book = \BookStack\Book::all()->first();
11         $page = $book->pages->first();
12
13         $this->asAdmin()
14             ->visit('/')
15             ->type($page->name, 'term')
16             ->press('header-search-box-button')
17             ->see('Search Results')
18             ->see($page->name)
19             ->click($page->name)
20             ->seePageIs($page->getUrl());
21     }
22
23     public function test_invalid_page_search()
24     {
25         $this->asAdmin()
26             ->visit('/')
27             ->type('<p>test</p>', 'term')
28             ->press('header-search-box-button')
29             ->see('Search Results')
30             ->seeStatusCode(200);
31     }
32
33     public function test_empty_search_redirects_back()
34     {
35         $this->asAdmin()
36             ->visit('/')
37             ->visit('/search/all')
38             ->seePageIs('/');
39     }
40
41     public function test_book_search()
42     {
43         $book = \BookStack\Book::all()->first();
44         $page = $book->pages->last();
45         $chapter = $book->chapters->last();
46
47         $this->asAdmin()
48             ->visit('/search/book/' . $book->id . '?term=' . urlencode($page->name))
49             ->see($page->name)
50
51             ->visit('/search/book/' . $book->id  . '?term=' . urlencode($chapter->name))
52             ->see($chapter->name);
53     }
54
55     public function test_empty_book_search_redirects_back()
56     {
57         $book = \BookStack\Book::all()->first();
58         $this->asAdmin()
59             ->visit('/books')
60             ->visit('/search/book/' . $book->id . '?term=')
61             ->seePageIs('/books');
62     }
63
64
65     public function test_pages_search_listing()
66     {
67         $page = \BookStack\Page::all()->last();
68         $this->asAdmin()->visit('/search/pages?term=' . $page->name)
69             ->see('Page Search Results')->see('.entity-list', $page->name);
70     }
71
72     public function test_chapters_search_listing()
73     {
74         $chapter = \BookStack\Chapter::all()->last();
75         $this->asAdmin()->visit('/search/chapters?term=' . $chapter->name)
76             ->see('Chapter Search Results')->seeInElement('.entity-list', $chapter->name);
77     }
78
79     public function test_books_search_listing()
80     {
81         $book = \BookStack\Book::all()->last();
82         $this->asAdmin()->visit('/search/books?term=' . $book->name)
83             ->see('Book Search Results')->see('.entity-list', $book->name);
84     }
85 }