public function ContextHandlerTest::testApplyContextMappingAlreadyApplied in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Plugin/ContextHandlerTest.php \Drupal\KernelTests\Core\Plugin\ContextHandlerTest::testApplyContextMappingAlreadyApplied()
- 9 core/tests/Drupal/KernelTests/Core/Plugin/ContextHandlerTest.php \Drupal\KernelTests\Core\Plugin\ContextHandlerTest::testApplyContextMappingAlreadyApplied()
@covers ::applyContextMapping
File
- core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ ContextHandlerTest.php, line 50
Class
- ContextHandlerTest
- @coversDefaultClass \Drupal\Core\Plugin\Context\ContextHandler
Namespace
Drupal\KernelTests\Core\PluginCode
public function testApplyContextMappingAlreadyApplied() {
$entity = EntityTest::create([]);
$context_definition = EntityContextDefinition::fromEntity($entity);
$context = EntityContext::fromEntity($entity);
$definition = [
'context_definitions' => [
'a_context_id' => $context_definition,
],
];
$plugin = new TestContextAwarePlugin([], 'test_plugin_id', $definition);
$plugin
->setContext('a_context_id', $context);
(new ContextHandler())
->applyContextMapping($plugin, []);
$result = $plugin
->getContext('a_context_id');
$this
->assertInstanceOf(EntityContext::class, $result);
$this
->assertSame($context, $result);
}