public function LayoutBuilderTest::testAccess in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testAccess()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testAccess()
Test that layout builder checks entity view access.
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTest.php, line 453
Class
- LayoutBuilderTest
- Tests the Layout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testAccess() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Allow overrides for the layout.
$this
->drupalPostForm("{$field_ui_prefix}/display/default", [
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalPostForm("{$field_ui_prefix}/display/default", [
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
]));
$this
->drupalGet('node/1');
$assert_session
->pageTextContains('The first node body');
$assert_session
->pageTextNotContains('Powered by Drupal');
$node = Node::load(1);
$node
->setUnpublished();
$node
->save();
$this
->drupalGet('node/1');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextContains('Access denied');
$this
->drupalGet('node/1/layout');
$assert_session
->pageTextNotContains('The first node body');
$assert_session
->pageTextContains('Access denied');
}