X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e108808a32b865668076b7b032ee620229d44d1f..refs/pull/2227/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index 3d12ed749..de1e025ad 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -1,4 +1,4 @@ -seeInElement('#recently-updated-pages', $page->name); } - public function test_slug_multi_byte_lower_casing() + public function test_slug_multi_byte_url_safe() { $book = $this->newBook([ - 'name' => 'КНИГА' + '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() { @@ -315,4 +322,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' => '', + ]); + } + }