public function InlineBlockTest::testEditInlineBlocksPermission 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::testEditInlineBlocksPermission()
Tests 'create and edit custom blocks' permission to edit an existing block.
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ InlineBlockTest.php, line 620
Class
- InlineBlockTest
- Tests that the inline block feature works correctly.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testEditInlineBlocksPermission() {
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save();
$this
->drupalLogin($this
->drupalCreateUser([
'access contextual links',
'configure any layout',
'administer node display',
'create and edit custom blocks',
]));
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$this
->addInlineBlockToLayout('The block label', 'The body value');
$assert = function ($permissions, $expected) {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser($permissions));
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$this
->clickContextualLink(static::INLINE_BLOCK_LOCATOR, 'Configure');
$assert_session
->assertWaitOnAjaxRequest();
if ($expected) {
$assert_session
->fieldExists('settings[block_form][body][0][value]');
}
else {
$assert_session
->fieldNotExists('settings[block_form][body][0][value]');
}
};
$permissions = [
'access contextual links',
'configure any layout',
'administer node display',
];
$assert($permissions, FALSE);
$permissions[] = 'create and edit custom blocks';
$assert($permissions, TRUE);
}