X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..refs/pull/3113/head:/tests/Entity/BookShelfTest.php diff --git a/tests/Entity/BookShelfTest.php b/tests/Entity/BookShelfTest.php index cc9a7e44e..fcbc17ea9 100644 --- a/tests/Entity/BookShelfTest.php +++ b/tests/Entity/BookShelfTest.php @@ -37,7 +37,7 @@ class BookShelfTest extends TestCase public function test_shelves_shows_in_header_if_have_any_shelve_view_permission() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->giveUserPermissions($user, ['image-create-all']); $shelf = Bookshelf::first(); $userRole = $user->roles()->first(); @@ -290,7 +290,7 @@ class BookShelfTest extends TestCase $shelf = Bookshelf::first(); $resp = $this->asAdmin()->get($shelf->getUrl('/permissions')); $resp->assertSeeText('Copy Permissions'); - $resp->assertSee("action=\"{$shelf->getUrl('/copy-permissions')}\""); + $resp->assertSee("action=\"{$shelf->getUrl('/copy-permissions')}\"", false); $child = $shelf->books()->first(); $editorRole = $this->getEditor()->roles()->first(); @@ -308,6 +308,13 @@ class BookShelfTest extends TestCase $this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]); } + public function test_permission_page_has_a_warning_about_no_cascading() + { + $shelf = Bookshelf::first(); + $resp = $this->asAdmin()->get($shelf->getUrl('/permissions')); + $resp->assertSeeText('Permissions on bookshelves do not automatically cascade to contained books.'); + } + public function test_bookshelves_show_in_breadcrumbs_if_in_context() { $shelf = Bookshelf::first(); @@ -362,4 +369,12 @@ class BookShelfTest extends TestCase $resp = $this->asEditor()->get($newBook->getUrl()); $resp->assertDontSee($shelfInfo['name']); } + + public function test_cancel_on_child_book_creation_returns_to_original_shelf() + { + /** @var Bookshelf $shelf */ + $shelf = Bookshelf::query()->first(); + $resp = $this->asEditor()->get($shelf->getUrl('/create-book')); + $resp->assertElementContains('form a[href="' . $shelf->getUrl() . '"]', 'Cancel'); + } }