function LayoutBuilderIsActiveCacheContextTest::testGetContextNonFieldableEntity

Same name in other branches
  1. 10 core/modules/layout_builder/tests/src/Unit/LayoutBuilderIsActiveCacheContextTest.php \Drupal\Tests\layout_builder\Unit\LayoutBuilderIsActiveCacheContextTest::testGetContextNonFieldableEntity()
  2. 11.x core/modules/layout_builder/tests/src/Unit/LayoutBuilderIsActiveCacheContextTest.php \Drupal\Tests\layout_builder\Unit\LayoutBuilderIsActiveCacheContextTest::testGetContextNonFieldableEntity()

@covers ::getContext @covers ::getDisplay

File

core/modules/layout_builder/tests/src/Unit/LayoutBuilderIsActiveCacheContextTest.php, line 39

Class

LayoutBuilderIsActiveCacheContextTest
@coversDefaultClass \Drupal\layout_builder\Cache\LayoutBuilderIsActiveCacheContext

Namespace

Drupal\Tests\layout_builder\Unit

Code

public function testGetContextNonFieldableEntity() {
    $route_match = $this->prophesize(RouteMatchInterface::class);
    $route_match->getParameter('not_a_fieldable_entity')
        ->willReturn('something that is not a fieldable entity');
    $cache_context = new LayoutBuilderIsActiveCacheContext($route_match->reveal());
    $expected = '0';
    $actual = $cache_context->getContext('not_a_fieldable_entity');
    $this->assertSame($expected, $actual);
}

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