You are here

protected function BlockPlacementBlacklistTest::setUp in Layout Builder Restrictions 8.2

Overrides LayoutBuilderRestrictionsTestBase::setUp

File

modules/layout_builder_restrictions_by_region/tests/src/FunctionalJavascript/BlockPlacementBlacklistTest.php, line 30

Class

BlockPlacementBlacklistTest
Demonstrate that blocks can be individually restricted.

Namespace

Drupal\Tests\layout_builder_restrictions_by_region\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'access administration pages',
    'administer blocks',
    'administer node display',
    'administer node fields',
    'configure any layout',
    'configure layout builder restrictions',
    'create and edit custom blocks',
  ]));

  // Enable entity_view_mode_restriction_by_region plugin.
  // Disable entity_view_mode_restriction plugin.
  $layout_builder_restrictions_plugins = [
    'entity_view_mode_restriction' => [
      'weight' => 1,
      'enabled' => FALSE,
    ],
    'entity_view_mode_restriction_by_region' => [
      'weight' => 0,
      'enabled' => TRUE,
    ],
  ];
  $config = \Drupal::service('config.factory')
    ->getEditable('layout_builder_restrictions.plugins');
  $config
    ->set('plugin_config', $layout_builder_restrictions_plugins)
    ->save();
}