X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/991dd8a558456b5aa669a60fd06a35270697a2ab..cd6572b61af2165133468d2562d04dffdca8fca8:/tests/Entity/SortTest.php diff --git a/tests/Entity/SortTest.php b/tests/Entity/SortTest.php index 2f2f9109d..4784297a2 100644 --- a/tests/Entity/SortTest.php +++ b/tests/Entity/SortTest.php @@ -13,8 +13,8 @@ class SortTest extends TestCase public function test_drafts_do_not_show_up() { $this->asAdmin(); - $pageRepo = app('\BookStack\Repos\PageRepo'); - $draft = $pageRepo->getDraftPage($this->book); + $entityRepo = app('\BookStack\Repos\EntityRepo'); + $draft = $entityRepo->getDraftPage($this->book); $this->visit($this->book->getUrl()) ->see($draft->name) @@ -28,7 +28,7 @@ class SortTest extends TestCase $currentBook = $page->book; $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first(); $this->asAdmin()->visit($page->getUrl() . '/move') - ->see('Move Page')->see($page->name) + ->see('Move Page') ->type('book:' . $newBook->id, 'entity_selection')->press('Move Page'); $page = \BookStack\Page::find($page->id); @@ -40,4 +40,29 @@ class SortTest extends TestCase ->seeInNthElement('.activity-list-item', 0, $page->name); } + public function test_chapter_move() + { + $chapter = \BookStack\Chapter::first(); + $currentBook = $chapter->book; + $pageToCheck = $chapter->pages->first(); + $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first(); + + $this->asAdmin()->visit($chapter->getUrl() . '/move') + ->see('Move Chapter') + ->type('book:' . $newBook->id, 'entity_selection')->press('Move Chapter'); + + $chapter = \BookStack\Chapter::find($chapter->id); + $this->seePageIs($chapter->getUrl()); + $this->assertTrue($chapter->book->id === $newBook->id, 'Chapter Book is now the new book'); + + $this->visit($newBook->getUrl()) + ->seeInNthElement('.activity-list-item', 0, 'moved chapter') + ->seeInNthElement('.activity-list-item', 0, $chapter->name); + + $pageToCheck = \BookStack\Page::find($pageToCheck->id); + $this->assertTrue($pageToCheck->book_id === $newBook->id, 'Chapter child page\'s book id has changed to the new book'); + $this->visit($pageToCheck->getUrl()) + ->see($newBook->name); + } + } \ No newline at end of file