]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/RecycleBinApiTest.php
Updated js dev docs with latest component changes
[bookstack] / tests / Api / RecycleBinApiTest.php
index 05c896bd9632a47f9da1e9f546e4f79b46cb5321..bc7249987dd0da3e01a9d7ee777d336ffb8b98af 100644 (file)
@@ -4,7 +4,6 @@ namespace Tests\Api;
 
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Deletion;
-use BookStack\Entities\Models\Page;
 use Illuminate\Support\Collection;
 use Tests\TestCase;
 
@@ -50,8 +49,8 @@ class RecycleBinApiTest extends TestCase
     {
         $admin = $this->getAdmin();
 
-        $page = Page::query()->first();
-        $book = Book::query()->first();
+        $page = $this->entities->page();
+        $book = $this->entities->book();
         $this->actingAs($admin)->delete($page->getUrl());
         $this->delete($book->getUrl());
 
@@ -111,7 +110,7 @@ class RecycleBinApiTest extends TestCase
     public function test_index_endpoint_returns_parent()
     {
         $admin = $this->getAdmin();
-        $page = Page::query()->whereHas('chapter')->with('chapter')->first();
+        $page = $this->entities->pageWithinChapter();
 
         $this->actingAs($admin)->delete($page->getUrl());
         $deletion = Deletion::query()->orderBy('id')->first();
@@ -125,9 +124,9 @@ class RecycleBinApiTest extends TestCase
                     'parent' => [
                         'id'   => $page->chapter->id,
                         'name' => $page->chapter->name,
-                        'type' => 'chapter'
-                    ]
-                ]
+                        'type' => 'chapter',
+                    ],
+                ],
             ],
         ];
 
@@ -139,7 +138,7 @@ class RecycleBinApiTest extends TestCase
 
     public function test_restore_endpoint()
     {
-        $page = Page::query()->first();
+        $page = $this->entities->page();
         $this->asAdmin()->delete($page->getUrl());
         $page->refresh();
 
@@ -152,7 +151,7 @@ class RecycleBinApiTest extends TestCase
 
         $resp = $this->putJson($this->baseEndpoint . '/' . $deletion->id);
         $resp->assertJson([
-            'restore_count' => 1
+            'restore_count' => 1,
         ]);
 
         $this->assertDatabaseHas('pages', [
@@ -163,7 +162,7 @@ class RecycleBinApiTest extends TestCase
 
     public function test_destroy_endpoint()
     {
-        $page = Page::query()->first();
+        $page = $this->entities->page();
         $this->asAdmin()->delete($page->getUrl());
         $page->refresh();
 
@@ -176,7 +175,7 @@ class RecycleBinApiTest extends TestCase
 
         $resp = $this->deleteJson($this->baseEndpoint . '/' . $deletion->id);
         $resp->assertJson([
-            'delete_count' => 1
+            'delete_count' => 1,
         ]);
 
         $this->assertDatabaseMissing('pages', ['id' => $page->id]);