public function InlineBlockTest::testAccess in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTest::testAccess()
Tests access to the block edit form of inline blocks.
This module does not provide links to these forms but in case the paths are accessed directly they should accessible by users with the 'configure any layout' permission.
See also
layout_builder_block_content_access()
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ InlineBlockTest.php, line 477
Class
- InlineBlockTest
- Tests that the inline block feature works correctly.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testAccess() {
$this
->drupalLogin($this
->drupalCreateUser([
'access contextual links',
'configure any layout',
'administer node display',
'administer node fields',
'create and edit custom blocks',
]));
$assert_session = $this
->assertSession();
// Enable layout builder and overrides.
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
'layout[allow_custom]' => TRUE,
], 'Save');
// Ensure we have 2 copies of the block in node overrides.
$this
->drupalGet('node/1/layout');
$this
->addInlineBlockToLayout('Block title', 'Block body');
$this
->assertSaveLayout();
$node_1_block_id = $this
->getLatestBlockEntityId();
$this
->drupalGet("block/{$node_1_block_id}");
$assert_session
->pageTextNotContains('You are not authorized to access this page');
$this
->drupalLogout();
$this
->drupalLogin($this
->drupalCreateUser([
'administer nodes',
]));
$this
->drupalGet("block/{$node_1_block_id}");
$assert_session
->pageTextContains('You are not authorized to access this page');
$this
->drupalLogin($this
->drupalCreateUser([
'create and edit custom blocks',
]));
$this
->drupalGet("block/{$node_1_block_id}");
$assert_session
->pageTextNotContains('You are not authorized to access this page');
}