1 <?php namespace Tests\Entity;
3 use BookStack\Entities\Models\Chapter;
6 class ChapterTest extends TestCase
8 public function test_chapter_delete()
10 $chapter = Chapter::query()->whereHas('pages')->first();
11 $this->assertNull($chapter->deleted_at);
12 $pageCount = $chapter->pages()->count();
14 $deleteViewReq = $this->asEditor()->get($chapter->getUrl('/delete'));
15 $deleteViewReq->assertSeeText('Are you sure you want to delete this chapter?');
17 $deleteReq = $this->delete($chapter->getUrl());
18 $deleteReq->assertRedirect($chapter->getParent()->getUrl());
19 $this->assertActivityExists('chapter_delete', $chapter);
22 $this->assertNotNull($chapter->deleted_at);
24 $this->assertTrue($chapter->pages()->count() === 0);
25 $this->assertTrue($chapter->pages()->withTrashed()->count() === $pageCount);
26 $this->assertTrue($chapter->deletions()->count() === 1);
28 $redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
29 $redirectReq->assertNotificationContains('Chapter Successfully Deleted');