2017-02-04 12:58:42 +01:00
|
|
|
<?php namespace Tests;
|
2016-04-15 20:51:27 +02:00
|
|
|
|
2017-01-25 20:35:40 +01:00
|
|
|
class SortTest extends BrowserKitTest
|
2016-04-15 20:51:27 +02:00
|
|
|
{
|
|
|
|
protected $book;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->book = \BookStack\Book::first();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_drafts_do_not_show_up()
|
|
|
|
{
|
|
|
|
$this->asAdmin();
|
2017-01-02 12:07:27 +01:00
|
|
|
$entityRepo = app('\BookStack\Repos\EntityRepo');
|
|
|
|
$draft = $entityRepo->getDraftPage($this->book);
|
2016-04-15 20:51:27 +02:00
|
|
|
|
|
|
|
$this->visit($this->book->getUrl())
|
|
|
|
->see($draft->name)
|
|
|
|
->visit($this->book->getUrl() . '/sort')
|
|
|
|
->dontSee($draft->name);
|
|
|
|
}
|
|
|
|
|
2016-06-12 13:48:06 +02:00
|
|
|
public function test_page_move()
|
|
|
|
{
|
|
|
|
$page = \BookStack\Page::first();
|
|
|
|
$currentBook = $page->book;
|
|
|
|
$newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
|
|
|
|
$this->asAdmin()->visit($page->getUrl() . '/move')
|
2016-12-03 19:35:40 +01:00
|
|
|
->see('Move Page')
|
2016-06-12 13:48:06 +02:00
|
|
|
->type('book:' . $newBook->id, 'entity_selection')->press('Move Page');
|
|
|
|
|
|
|
|
$page = \BookStack\Page::find($page->id);
|
|
|
|
$this->seePageIs($page->getUrl());
|
|
|
|
$this->assertTrue($page->book->id == $newBook->id, 'Page book is now the new book');
|
|
|
|
|
|
|
|
$this->visit($newBook->getUrl())
|
|
|
|
->seeInNthElement('.activity-list-item', 0, 'moved page')
|
|
|
|
->seeInNthElement('.activity-list-item', 0, $page->name);
|
|
|
|
}
|
|
|
|
|
2016-06-25 16:31:38 +02:00
|
|
|
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')
|
2016-12-04 15:08:04 +01:00
|
|
|
->see('Move Chapter')
|
2016-06-25 16:31:38 +02:00
|
|
|
->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);
|
|
|
|
}
|
|
|
|
|
2016-04-15 20:51:27 +02:00
|
|
|
}
|