You are here

public function OverridesSectionStorageTest::testGetContexts in Drupal 10

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

@covers ::getContexts

File

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

Class

OverridesSectionStorageTest
@coversDefaultClass \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage

Namespace

Drupal\Tests\layout_builder\Kernel

Code

public function testGetContexts() {
  $entity = EntityTest::create();
  $entity
    ->save();
  $context = EntityContext::fromEntity($entity);
  $this->plugin
    ->setContext('entity', $context);
  $expected = [
    'entity',
    'view_mode',
  ];
  $result = $this->plugin
    ->getContexts();
  $this
    ->assertEquals($expected, array_keys($result));
  $this
    ->assertSame($context, $result['entity']);
}