function OverridesSectionStorageTest::testDeriveContextsFromRoute

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\OverridesSectionStorageTest::testDeriveContextsFromRoute()
  2. 10 core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\OverridesSectionStorageTest::testDeriveContextsFromRoute()
  3. 11.x core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php \Drupal\Tests\layout_builder\Kernel\OverridesSectionStorageTest::testDeriveContextsFromRoute()

@covers ::deriveContextsFromRoute

File

core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php, line 251

Class

OverridesSectionStorageTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21layout_builder%21src%21Plugin%21SectionStorage%21OverridesSectionStorage.php/class/OverridesSectionStorage/8.9.x" title="Defines the &#039;overrides&#039; section storage type." class="local">\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage</a>

Namespace

Drupal\Tests\layout_builder\Kernel

Code

public function testDeriveContextsFromRoute() {
    $display = LayoutBuilderEntityViewDisplay::create([
        'targetEntityType' => 'entity_test',
        'bundle' => 'entity_test',
        'mode' => 'default',
        'status' => TRUE,
    ]);
    $display->enableLayoutBuilder()
        ->setOverridable()
        ->save();
    $entity = EntityTest::create();
    $entity->save();
    $entity = EntityTest::load($entity->id());
    $result = $this->plugin
        ->deriveContextsFromRoute('entity_test.1', [], '', []);
    $this->assertSame([
        'entity',
        'view_mode',
    ], array_keys($result));
    $this->assertSame($entity, $result['entity']->getContextValue());
    $this->assertSame('default', $result['view_mode']->getContextValue());
}

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