LayoutRestrictionsTest.php in Layout Builder Restrictions 8.2
File
tests/src/FunctionalJavascript/LayoutRestrictionsTest.php
View source
<?php
namespace Drupal\Tests\layout_builder_restrictions\FunctionalJavascript;
class LayoutRestrictionsTest extends LayoutBuilderRestrictionsTestBase {
public function testLayoutRestriction() {
$blocks = $this
->generateTestBlocks();
$node_id = $this
->generateTestNode();
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->navigateToNodeSettingsTray($node_id);
$this
->clickLink('Add section');
$this
->assertNotEmpty($assert_session
->waitForText('Choose a layout for this section'));
$assert_session
->linkExists('One column');
$assert_session
->linkExists('Two column');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layout-restriction-all"]');
$assert_session
->checkboxChecked('edit-layout-builder-restrictions-allowed-layouts-layout-restriction-all');
$assert_session
->checkboxNotChecked('edit-layout-builder-restrictions-allowed-layouts-layout-restriction-restricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layout-restriction-restricted"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layouts-layout-twocol-section"]');
$element
->click();
$page
->pressButton('Save');
$this
->navigateToNodeSettingsTray($node_id);
$this
->clickLink('Add section');
$this
->assertNotEmpty($assert_session
->waitForText('Choose a layout for this section'));
$assert_session
->linkNotExists('One column');
$assert_session
->linkExists('Two column');
}
}