]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/BookShelfTest.php
API: Added endpoints for reading image data
[bookstack] / tests / Entity / BookShelfTest.php
index ad1d64e7126570c7e3388a0201e39c2adef66edd..3ba2c3e99c8839d91ad60bdddceaee85efe9dd4d 100644 (file)
@@ -91,7 +91,7 @@ class BookShelfTest extends TestCase
         ]));
         $resp->assertRedirect();
         $editorId = $this->users->editor()->id;
-        $this->assertDatabaseHas('bookshelves', array_merge($shelfInfo, ['created_by' => $editorId, 'updated_by' => $editorId]));
+        $this->assertDatabaseHasEntityData('bookshelf', array_merge($shelfInfo, ['created_by' => $editorId, 'updated_by' => $editorId]));
 
         $shelf = Bookshelf::where('name', '=', $shelfInfo['name'])->first();
         $shelfPage = $this->get($shelf->getUrl());
@@ -117,11 +117,12 @@ class BookShelfTest extends TestCase
 
         $lastImage = Image::query()->orderByDesc('id')->firstOrFail();
         $shelf = Bookshelf::query()->where('name', '=', $shelfInfo['name'])->first();
-        $this->assertDatabaseHas('bookshelves', [
-            'id'       => $shelf->id,
+        $this->assertDatabaseHas('entity_container_data', [
+            'entity_id'       => $shelf->id,
+            'entity_type' => 'bookshelf',
             'image_id' => $lastImage->id,
         ]);
-        $this->assertEquals($lastImage->id, $shelf->cover->id);
+        $this->assertEquals($lastImage->id, $shelf->coverInfo()->getImage()->id);
         $this->assertEquals('cover_bookshelf', $lastImage->type);
     }
 
@@ -247,7 +248,7 @@ class BookShelfTest extends TestCase
         $this->assertSessionHas('success');
 
         $editorId = $this->users->editor()->id;
-        $this->assertDatabaseHas('bookshelves', array_merge($shelfInfo, ['id' => $shelf->id, 'created_by' => $editorId, 'updated_by' => $editorId]));
+        $this->assertDatabaseHasEntityData('bookshelf', array_merge($shelfInfo, ['id' => $shelf->id, 'created_by' => $editorId, 'updated_by' => $editorId]));
 
         $shelfPage = $this->get($shelf->getUrl());
         $shelfPage->assertSee($shelfInfo['name']);