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