function DefaultsSectionStorageTest::testAccess

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\DefaultsSectionStorageTest::testAccess()
  2. 8.9.x core/modules/layout_builder/tests/src/Kernel/DefaultsSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\DefaultsSectionStorageTest::testAccess()
  3. 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) : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.