]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/BooksApiTest.php
Move logFailedAccess into Activity
[bookstack] / tests / Api / BooksApiTest.php
index f560bfffdaef1dfa6b1126157db83fd23efcaca8..a40e4c93b6c43aab535dee805b78a7c91b6517a3 100644 (file)
@@ -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();