function DefaultsSectionStorageTest::testAccess

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()
  3. 11.x 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 <a href="/api/drupal/core%21modules%21layout_builder%21src%21Plugin%21SectionStorage%21DefaultsSectionStorage.php/class/DefaultsSectionStorage/8.9.x" title="Defines the &#039;defaults&#039; section storage type." class="local">\Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage</a>

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);
}

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