public function ContextAwarePluginTraitTest::testSetContextValue in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginTraitTest.php \Drupal\KernelTests\Core\Plugin\Context\ContextAwarePluginTraitTest::testSetContextValue()
@covers ::setContextValue
File
- core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Context/ ContextAwarePluginTraitTest.php, line 81
Class
- ContextAwarePluginTraitTest
- @coversDefaultClass \Drupal\Core\Plugin\ContextAwarePluginTrait
Namespace
Drupal\KernelTests\Core\Plugin\ContextCode
public function testSetContextValue() {
$typed_data_manager = $this
->prophesize(TypedDataManagerInterface::class);
$container = new ContainerBuilder();
$container
->set('typed_data_manager', $typed_data_manager
->reveal());
\Drupal::setContainer($container);
$this->plugin
->getPluginDefinition()
->addContextDefinition('foo', new ContextDefinition('string'));
$this
->assertFalse($this->plugin->setContextCalled);
$this->plugin
->setContextValue('foo', new StringData(new DataDefinition(), 'bar'));
$this
->assertTrue($this->plugin->setContextCalled);
}