X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/04a86141361e941d2053ca16181e7561bff27650..refs/pull/1881/head:/tests/Api/BooksApiTest.php diff --git a/tests/Api/BooksApiTest.php b/tests/Api/BooksApiTest.php index f560bfffd..a40e4c93b 100644 --- a/tests/Api/BooksApiTest.php +++ b/tests/Api/BooksApiTest.php @@ -2,7 +2,7 @@ use BookStack\Entities\Book; -class ApiAuthTest extends TestCase +class BooksApiTest extends TestCase { use TestsApi; @@ -38,6 +38,26 @@ class ApiAuthTest extends TestCase $this->assertActivityExists('book_create', $newItem); } + public function test_book_name_needed_to_create() + { + $this->actingAsApiEditor(); + $details = [ + 'description' => 'A book created via the API', + ]; + + $resp = $this->postJson($this->baseEndpoint, $details); + $resp->assertStatus(422); + $resp->assertJson([ + "error" => [ + "message" => "The given data was invalid.", + "validation" => [ + "name" => ["The name field is required."] + ], + "code" => 422, + ], + ]); + } + public function test_read_endpoint() { $this->actingAsApiEditor();