public function InlineBlockTest::testAddInlineBlocksPermission 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::testAddInlineBlocksPermission()
Tests the 'create and edit custom blocks' permission to add a new block.
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ InlineBlockTest.php, line 586
Class
- InlineBlockTest
- Tests that the inline block feature works correctly.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testAddInlineBlocksPermission() {
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save();
$assert = function ($permissions, $expected) {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser($permissions));
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$page
->clickLink('Add block');
$this
->assertNotEmpty($assert_session
->waitForElementVisible('css', '#drupal-off-canvas .block-categories'));
if ($expected) {
$assert_session
->linkExists('Create custom block');
}
else {
$assert_session
->linkNotExists('Create custom block');
}
};
$permissions = [
'configure any layout',
'administer node display',
];
$assert($permissions, FALSE);
$permissions[] = 'create and edit custom blocks';
$assert($permissions, TRUE);
}