]> BookStack Code Mirror - bookstack/blob - tests/Entity/ChapterTest.php
fix image delete confirm text
[bookstack] / tests / Entity / ChapterTest.php
1 <?php namespace Tests\Entity;
2
3 use BookStack\Entities\Models\Chapter;
4 use Tests\TestCase;
5
6 class ChapterTest extends TestCase
7 {
8     public function test_chapter_delete()
9     {
10         $chapter = Chapter::query()->whereHas('pages')->first();
11         $this->assertNull($chapter->deleted_at);
12         $pageCount = $chapter->pages()->count();
13
14         $deleteViewReq = $this->asEditor()->get($chapter->getUrl('/delete'));
15         $deleteViewReq->assertSeeText('Are you sure you want to delete this chapter?');
16
17         $deleteReq = $this->delete($chapter->getUrl());
18         $deleteReq->assertRedirect($chapter->getParent()->getUrl());
19         $this->assertActivityExists('chapter_delete', $chapter);
20
21         $chapter->refresh();
22         $this->assertNotNull($chapter->deleted_at);
23
24         $this->assertTrue($chapter->pages()->count() === 0);
25         $this->assertTrue($chapter->pages()->withTrashed()->count() === $pageCount);
26         $this->assertTrue($chapter->deletions()->count() === 1);
27
28         $redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
29         $redirectReq->assertNotificationContains('Chapter Successfully Deleted');
30     }
31 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.