You are here

public function DefaultsSectionStorageTest::testAccess in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\DefaultsSectionStorageTest::testAccess()
  2. 10 core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\DefaultsSectionStorageTest::testAccess()

@covers ::access @dataProvider providerTestAccess

Parameters

bool $expected: The expected outcome of ::access().

string $operation: The operation to pass to ::access().

bool $is_enabled: Whether Layout Builder is enabled for this display.

array $section_data: Data to store as the sections value for Layout Builder.

File

core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php, line 91

Class

DefaultsSectionStorageTest
@coversDefaultClass \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage

Namespace

Drupal\Tests\layout_builder\Kernel

Code

public function testAccess($expected, $operation, $is_enabled, array $section_data) {
  $display = LayoutBuilderEntityViewDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    'mode' => 'default',
    'status' => TRUE,
  ]);
  if ($is_enabled) {
    $display
      ->enableLayoutBuilder();
  }
  $display
    ->setThirdPartySetting('layout_builder', 'sections', $section_data)
    ->save();
  $this->plugin
    ->setContext('display', EntityContext::fromEntity($display));
  $result = $this->plugin
    ->access($operation);
  $this
    ->assertSame($expected, $result);
}