]> BookStack Code Mirror - bookstack/commitdiff
Added test for page move into chapter
authorDan Brown <redacted>
Tue, 29 Oct 2019 22:25:53 +0000 (22:25 +0000)
committerDan Brown <redacted>
Tue, 29 Oct 2019 22:25:53 +0000 (22:25 +0000)
tests/Entity/SortTest.php

index 3c83d626aea73632dc93a5d08274a1a4d6e420da..d7c004dc852982537c75897af4200a6c2e6862fa 100644 (file)
@@ -28,7 +28,7 @@ class SortTest extends TestCase
         $resp->assertDontSee($draft->name);
     }
 
-    public function test_page_move()
+    public function test_page_move_into_book()
     {
         $page = Page::first();
         $currentBook = $page->book;
@@ -50,6 +50,26 @@ class SortTest extends TestCase
         $newBookResp->assertSee($page->name);
     }
 
+    public function test_page_move_into_chapter()
+    {
+        $page = Page::first();
+        $currentBook = $page->book;
+        $newBook = Book::where('id', '!=', $currentBook->id)->first();
+        $newChapter = $newBook->chapters()->first();
+
+        $movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
+            'entity_selection' => 'chapter:' . $newChapter->id
+        ]);
+        $page = Page::find($page->id);
+
+        $movePageResp->assertRedirect($page->getUrl());
+        $this->assertTrue($page->book->id == $newBook->id, 'Page parent is now the new chapter');
+
+        $newChapterResp = $this->get($newChapter->getUrl());
+        $newChapterResp->assertSee('moved page');
+        $newChapterResp->assertSee($page->name);
+    }
+
     public function test_page_move_requires_create_permissions_on_parent()
     {
         $page = Page::first();