function ContextAwarePluginBaseTest::testSetContextValue

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginBaseTest.php \Drupal\KernelTests\Core\Plugin\Context\ContextAwarePluginBaseTest::testSetContextValue()

@covers ::setContextValue

File

core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginBaseTest.php, line 79

Class

ContextAwarePluginBaseTest
@coversDefaultClass \Drupal\Core\Plugin\ContextAwarePluginBase

Namespace

Drupal\KernelTests\Core\Plugin\Context

Code

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->plugin
        ->expects($this->exactly(1))
        ->method('setContext');
    $this->plugin
        ->setContextValue('foo', new StringData(new DataDefinition(), 'bar'));
}

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