public function DefaultRestrictionsTest::testNewCategoriesRestricted in Layout Builder Restrictions 8.2
When new categories are restricted, a newly available block is restricted.
File
- tests/
src/ FunctionalJavascript/ DefaultRestrictionsTest.php, line 15
Class
- DefaultRestrictionsTest
- Demonstrate that blocks can be individually restricted.
Namespace
Drupal\Tests\layout_builder_restrictions\FunctionalJavascriptCode
public function testNewCategoriesRestricted() {
// Create 2 custom block types, with 3 block instances.
$blocks = $this
->generateTestBlocks();
$node_id = $this
->generateTestNode();
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// Impose Custom Block type restrictions.
$this
->navigateToManageDisplay();
// Restrict all new block categories.
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-block-categories-restricted"]');
$element
->click();
$page
->pressButton('Save');
// Enable the 'Help' module, which provides a plugin block.
$this->container
->get('module_installer')
->install([
'help',
]);
$this
->navigateToNodeSettingsTray($node_id);
// The 'Help' block is not allowed, even though there isn't a specific
// restriction.
$assert_session
->linkNotExists('Help');
// Other blocks are allowed because they are listed in the allowed_blocks
// schema.
$this
->clickLink('Create custom block');
$this
->assertNotEmpty($assert_session
->waitForText('Add a new custom block'));
$assert_session
->linkExists('Basic');
$assert_session
->linkExists('Alternate');
}