X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e108808a32b865668076b7b032ee620229d44d1f..refs/pull/2023/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index 3d12ed749..d7e4ec61c 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -1,4 +1,4 @@ -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' => '', + ]); + } + }