]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/SortTest.php
Merge branch 'v0.31.x'
[bookstack] / tests / Entity / SortTest.php
index f3f6a8a1a462e832347565e3ce65f9c5d8cedb21..c27c41f29120e83bb7e635568a4c5b98e6b9e261 100644 (file)
@@ -196,6 +196,24 @@ class SortTest extends TestCase
         $this->assertTrue($chapter->book->id == $newBook->id, 'Page book is now the new book');
     }
 
+    public function test_chapter_move_changes_book_for_deleted_pages_within()
+    {
+        /** @var Chapter $chapter */
+        $chapter = Chapter::query()->whereHas('pages')->first();
+        $currentBook = $chapter->book;
+        $pageToCheck = $chapter->pages->first();
+        $newBook = Book::query()->where('id', '!=', $currentBook->id)->first();
+
+        $pageToCheck->delete();
+
+        $this->asEditor()->put($chapter->getUrl('/move'), [
+            'entity_selection' => 'book:' . $newBook->id
+        ]);
+
+        $pageToCheck->refresh();
+        $this->assertEquals($newBook->id, $pageToCheck->book_id);
+    }
+
     public function test_book_sort()
     {
         $oldBook = Book::query()->first();