function LazyContextRepositoryTest::testGetRuntimeStaticCache

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php \Drupal\Tests\Core\Plugin\Context\LazyContextRepositoryTest::testGetRuntimeStaticCache()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php \Drupal\Tests\Core\Plugin\Context\LazyContextRepositoryTest::testGetRuntimeStaticCache()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php \Drupal\Tests\Core\Plugin\Context\LazyContextRepositoryTest::testGetRuntimeStaticCache()

@covers ::getRuntimeContexts

File

core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php, line 80

Class

LazyContextRepositoryTest
@coversDefaultClass \Drupal\Core\Plugin\Context\LazyContextRepository @group context

Namespace

Drupal\Tests\Core\Plugin\Context

Code

public function testGetRuntimeStaticCache() {
    $context0 = new Context(new ContextDefinition('example'));
    $context1 = new Context(new ContextDefinition('example'));
    $context_provider = $this->prophesize('\\Drupal\\Core\\Plugin\\Context\\ContextProviderInterface');
    $context_provider->getRuntimeContexts([
        'test_context0',
        'test_context1',
    ])
        ->shouldBeCalledTimes(1)
        ->willReturn([
        'test_context0' => $context0,
        'test_context1' => $context1,
    ]);
    $context_provider = $context_provider->reveal();
    $this->container
        ->set('test_provider', $context_provider);
    $lazy_context_repository = new LazyContextRepository($this->container, [
        'test_provider',
    ]);
    $lazy_context_repository->getRuntimeContexts([
        '@test_provider:test_context0',
        '@test_provider:test_context1',
    ]);
    $lazy_context_repository->getRuntimeContexts([
        '@test_provider:test_context0',
        '@test_provider:test_context1',
    ]);
}

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