]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/BooksApiTest.php
WYSWIYG: Allowed video/embed alignment controls
[bookstack] / tests / Api / BooksApiTest.php
index dd187672eaa2445e9956baa4496414ae235375be..c648faaf2f463977ad6cd2977c005fd6d488c2d7 100644 (file)
@@ -6,12 +6,10 @@ use BookStack\Entities\Models\Book;
 use Carbon\Carbon;
 use Illuminate\Support\Facades\DB;
 use Tests\TestCase;
-use Tests\Uploads\UsesImages;
 
 class BooksApiTest extends TestCase
 {
     use TestsApi;
-    use UsesImages;
 
     protected string $baseEndpoint = '/api/books';
 
@@ -33,13 +31,16 @@ class BooksApiTest extends TestCase
     public function test_create_endpoint()
     {
         $this->actingAsApiEditor();
+        $templatePage = $this->entities->templatePage();
         $details = [
             'name'        => 'My API book',
             'description' => 'A book created via the API',
+            'default_template_id' => $templatePage->id,
         ];
 
         $resp = $this->postJson($this->baseEndpoint, $details);
         $resp->assertStatus(200);
+
         $newItem = Book::query()->orderByDesc('id')->where('name', '=', $details['name'])->first();
         $resp->assertJson(array_merge($details, ['id' => $newItem->id, 'slug' => $newItem->slug]));
         $this->assertActivityExists('book_create', $newItem);
@@ -85,6 +86,7 @@ class BooksApiTest extends TestCase
             'owned_by' => [
                 'name' => $book->ownedBy->name,
             ],
+            'default_template_id' => null,
         ]);
     }
 
@@ -123,9 +125,11 @@ class BooksApiTest extends TestCase
     {
         $this->actingAsApiEditor();
         $book = $this->entities->book();
+        $templatePage = $this->entities->templatePage();
         $details = [
             'name'        => 'My updated API book',
             'description' => 'A book created via the API',
+            'default_template_id' => $templatePage->id,
         ];
 
         $resp = $this->putJson($this->baseEndpoint . "/{$book->id}", $details);
@@ -157,7 +161,7 @@ class BooksApiTest extends TestCase
         /** @var Book $book */
         $book = $this->entities->book();
         $this->assertNull($book->cover);
-        $file = $this->getTestImage('image.png');
+        $file = $this->files->uploadedImage('image.png');
 
         // Ensure cover image can be set via API
         $resp = $this->call('PUT', $this->baseEndpoint . "/{$book->id}", [