]> BookStack Code Mirror - bookstack/blob - tests/Entity/SortTest.php
Added tests to cover page_move features
[bookstack] / tests / Entity / SortTest.php
1 <?php
2
3 class SortTest extends TestCase
4 {
5     protected $book;
6
7     public function setUp()
8     {
9         parent::setUp();
10         $this->book = \BookStack\Book::first();
11     }
12
13     public function test_drafts_do_not_show_up()
14     {
15         $this->asAdmin();
16         $pageRepo = app('\BookStack\Repos\PageRepo');
17         $draft = $pageRepo->getDraftPage($this->book);
18
19         $this->visit($this->book->getUrl())
20             ->see($draft->name)
21             ->visit($this->book->getUrl() . '/sort')
22             ->dontSee($draft->name);
23     }
24
25     public function test_page_move()
26     {
27         $page = \BookStack\Page::first();
28         $currentBook = $page->book;
29         $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
30         $this->asAdmin()->visit($page->getUrl() . '/move')
31             ->see('Move Page')->see($page->name)
32             ->type('book:' . $newBook->id, 'entity_selection')->press('Move Page');
33
34         $page = \BookStack\Page::find($page->id);
35         $this->seePageIs($page->getUrl());
36         $this->assertTrue($page->book->id == $newBook->id, 'Page book is now the new book');
37
38         $this->visit($newBook->getUrl())
39             ->seeInNthElement('.activity-list-item', 0, 'moved page')
40             ->seeInNthElement('.activity-list-item', 0, $page->name);
41     }
42
43 }