]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/PagesApiTest.php
Refactor notify exception to clean up api exception handling
[bookstack] / tests / Api / PagesApiTest.php
index 12b38bc076aa8a61d3df534dacdec62f555b809a..75cc2807fa58fc8c5d5978474541d8c458eb4b60 100644 (file)
@@ -159,6 +159,27 @@ class PagesApiTest extends TestCase
         $this->assertStringContainsString('testing', $html);
     }
 
+    public function test_read_endpoint_returns_not_found()
+    {
+        $this->actingAsApiEditor();
+        // get an id that is not used
+        $id = Page::orderBy('id', 'desc')->first()->id + 1;
+        $this->assertNull(Page::find($id));
+
+        $resp = $this->getJson($this->baseEndpoint . "/$id");
+
+        $resp->assertNotFound();
+        $this->assertNull($resp->json('id'));
+        $resp->assertJsonIsObject('error');
+        $resp->assertJsonStructure([
+            'error' => [
+                'code',
+                'message',
+            ],
+        ]);
+        $this->assertSame(404, $resp->json('error')['code']);
+    }
+
     public function test_update_endpoint()
     {
         $this->actingAsApiEditor();