X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2f94f078e36cf65fa8c7b1d640c030b415714cdc..refs/pull/2515/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index c28ca8b3e..3a363e2b8 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -1,13 +1,13 @@ -bookCreation(); $chapter = $this->chapterCreation($book); - $page = $this->pageCreation($chapter); + $this->pageCreation($chapter); // Test Updating - $book = $this->bookUpdate($book); - - // Test Deletion - $this->bookDelete($book); - } - - public function bookDelete(Book $book) - { - $this->asAdmin() - ->visit($book->getUrl()) - // Check link works correctly - ->click('Delete') - ->seePageIs($book->getUrl() . '/delete') - // Ensure the book name is show to user - ->see($book->name) - ->press('Confirm') - ->seePageIs('/books') - ->notSeeInDatabase('books', ['id' => $book->id]); + $this->bookUpdate($book); } public function bookUpdate(Book $book) @@ -193,7 +176,7 @@ class EntityTest extends BrowserKitTest $entities = $this->createEntityChainBelongingToUser($creator, $updater); $this->actingAs($creator); app(UserRepo::class)->destroy($creator); - app(PageRepo::class)->savePageRevision($entities['page']); + app(PageRepo::class)->update($entities['page'], ['html' => '
hello!
>']); $this->checkEntitiesViewable($entities); } @@ -206,7 +189,7 @@ class EntityTest extends BrowserKitTest $entities = $this->createEntityChainBelongingToUser($creator, $updater); $this->actingAs($updater); app(UserRepo::class)->destroy($updater); - app(PageRepo::class)->savePageRevision($entities['page']); + app(PageRepo::class)->update($entities['page'], ['html' => 'Hello there!
']); $this->checkEntitiesViewable($entities); } @@ -272,21 +255,24 @@ class EntityTest extends BrowserKitTest ->seeInElement('#recently-updated-pages', $page->name); } - public function test_slug_multi_byte_lower_casing() + public function test_slug_multi_byte_url_safe() { - $entityRepo = app(EntityRepo::class); - $book = $entityRepo->createFromInput('book', [ - 'name' => 'ÐÐÐÐÐ' + $book = $this->newBook([ + 'name' => 'инÑоÑмаÑиÑ' ]); - $this->assertEquals('книга', $book->slug); - } + $this->assertEquals('informatsiya', $book->slug); + + $book = $this->newBook([ + 'name' => '¿Qué?' + ]); + $this->assertEquals('que', $book->slug); + } public function test_slug_format() { - $entityRepo = app(EntityRepo::class); - $book = $entityRepo->createFromInput('book', [ + $book = $this->newBook([ 'name' => 'PartA / PartB / PartC' ]); @@ -318,4 +304,14 @@ class EntityTest extends BrowserKitTest ->seePageIs($book->getUrl()); } + public function test_page_within_chapter_deletion_returns_to_chapter() + { + $chapter = Chapter::query()->first(); + $page = $chapter->pages()->first(); + + $this->asEditor()->visit($page->getUrl('/delete')) + ->submitForm('Confirm') + ->seePageIs($chapter->getUrl()); + } + }