X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2f94f078e36cf65fa8c7b1d640c030b415714cdc..refs/pull/2023/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index c28ca8b3e..d7e4ec61c 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -1,13 +1,14 @@ -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 +207,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); } @@ -274,8 +275,7 @@ class EntityTest extends BrowserKitTest public function test_slug_multi_byte_lower_casing() { - $entityRepo = app(EntityRepo::class); - $book = $entityRepo->createFromInput('book', [ + $book = $this->newBook([ 'name' => 'КНИГА' ]); @@ -285,8 +285,7 @@ class EntityTest extends BrowserKitTest public function test_slug_format() { - $entityRepo = app(EntityRepo::class); - $book = $entityRepo->createFromInput('book', [ + $book = $this->newBook([ 'name' => 'PartA / PartB / PartC' ]); @@ -318,4 +317,44 @@ 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()); + } + + public function test_page_delete_removes_entity_from_its_activity() + { + $page = Page::query()->first(); + + $this->asEditor()->put($page->getUrl(), [ + 'name' => 'My updated page', + 'html' => '

updated content

', + ]); + $page->refresh(); + + $this->seeInDatabase('activities', [ + 'entity_id' => $page->id, + 'entity_type' => $page->getMorphClass(), + ]); + + $resp = $this->delete($page->getUrl()); + $resp->assertResponseStatus(302); + + $this->dontSeeInDatabase('activities', [ + 'entity_id' => $page->id, + 'entity_type' => $page->getMorphClass(), + ]); + + $this->seeInDatabase('activities', [ + 'extra' => 'My updated page', + 'entity_id' => 0, + 'entity_type' => '', + ]); + } + }