function LazyContextRepositoryTest::setupContextAndProvider
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php \Drupal\Tests\Core\Plugin\Context\LazyContextRepositoryTest::setupContextAndProvider()
- 10 core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php \Drupal\Tests\Core\Plugin\Context\LazyContextRepositoryTest::setupContextAndProvider()
- 11.x core/tests/Drupal/Tests/Core/Plugin/Context/LazyContextRepositoryTest.php \Drupal\Tests\Core\Plugin\Context\LazyContextRepositoryTest::setupContextAndProvider()
Sets up contexts and context providers.
Parameters
string $service_id: The service ID of the service provider.
string[] $unqualified_context_ids: An array of context slot names.
string[] $expected_unqualified_context_ids: The expected unqualified context IDs passed to getRuntimeContexts.
Return value
array An array of set up contexts.
4 calls to LazyContextRepositoryTest::setupContextAndProvider()
- LazyContextRepositoryTest::testGetAvailableContexts in core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ LazyContextRepositoryTest.php - @covers ::getAvailableContexts
- LazyContextRepositoryTest::testGetRuntimeContextsSingle in core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ LazyContextRepositoryTest.php - @covers ::getRuntimeContexts
- LazyContextRepositoryTest::testGetRuntimeMultipleContextProviders in core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ LazyContextRepositoryTest.php - @covers ::getRuntimeContexts
- LazyContextRepositoryTest::testGetRuntimeMultipleContextsPerService in core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ LazyContextRepositoryTest.php - @covers ::getRuntimeContexts
File
-
core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ LazyContextRepositoryTest.php, line 128
Class
- LazyContextRepositoryTest
- @coversDefaultClass \Drupal\Core\Plugin\Context\LazyContextRepository @group context
Namespace
Drupal\Tests\Core\Plugin\ContextCode
protected function setupContextAndProvider($service_id, array $unqualified_context_ids, array $expected_unqualified_context_ids = []) {
$contexts = [];
for ($i = 0; $i < count($unqualified_context_ids); $i++) {
$contexts[] = new Context(new ContextDefinition('example'));
}
$expected_unqualified_context_ids = $expected_unqualified_context_ids ?: $unqualified_context_ids;
$context_provider = $this->prophesize('\\Drupal\\Core\\Plugin\\Context\\ContextProviderInterface');
$context_provider->getRuntimeContexts($expected_unqualified_context_ids)
->willReturn(array_combine($unqualified_context_ids, $contexts));
$context_provider->getAvailableContexts()
->willReturn(array_combine($unqualified_context_ids, $contexts));
$context_provider = $context_provider->reveal();
$this->container
->set($service_id, $context_provider);
return $contexts;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.