X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/98ab3c1ffb6cbc851ec73c73a4310cbbbca2a6ce..refs/pull/2023/head:/tests/Entity/BookShelfTest.php diff --git a/tests/Entity/BookShelfTest.php b/tests/Entity/BookShelfTest.php index b44761203..abee4d34a 100644 --- a/tests/Entity/BookShelfTest.php +++ b/tests/Entity/BookShelfTest.php @@ -1,10 +1,11 @@ -orderByDesc('id')->firstOrFail(); $shelf = Bookshelf::query()->where('name', '=', $shelfInfo['name'])->first(); $this->assertDatabaseHas('bookshelves', [ - 'id' => $shelf, + 'id' => $shelf->id, 'image_id' => $lastImage->id, ]); $this->assertEquals($lastImage->id, $shelf->cover->id); @@ -263,4 +264,32 @@ class BookShelfTest extends TestCase $pageVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName()); } + public function test_bookshelves_show_on_book() + { + // Create shelf + $shelfInfo = [ + 'name' => 'My test shelf' . Str::random(4), + 'description' => 'Test shelf description ' . Str::random(10) + ]; + + $this->asEditor()->post('/shelves', $shelfInfo); + $shelf = Bookshelf::where('name', '=', $shelfInfo['name'])->first(); + + // Create book and add to shelf + $this->asEditor()->post($shelf->getUrl('/create-book'), [ + 'name' => 'Test book name', + 'description' => 'Book in shelf description' + ]); + + $newBook = Book::query()->orderBy('id', 'desc')->first(); + + $resp = $this->asEditor()->get($newBook->getUrl()); + $resp->assertElementContains('.tri-layout-left-contents', $shelfInfo['name']); + + // Remove shelf + $this->delete($shelf->getUrl()); + + $resp = $this->asEditor()->get($newBook->getUrl()); + $resp->assertDontSee($shelfInfo['name']); + } }