From: Thomas Kuschan Date: Thu, 8 Jun 2023 07:53:53 +0000 (+0200) Subject: Add test showing the "HTTP 500 on not found" bug X-Git-Tag: v23.06~1^2~20^2~4 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/ecf99fa0edbddc5c47eb94b9cb3b5f22c65890ee Add test showing the "HTTP 500 on not found" bug --- diff --git a/tests/Api/PagesApiTest.php b/tests/Api/PagesApiTest.php index 12b38bc07..75cc2807f 100644 --- a/tests/Api/PagesApiTest.php +++ b/tests/Api/PagesApiTest.php @@ -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();