function ContextAwarePluginTraitTest::testSetContextValue

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginTraitTest.php \Drupal\KernelTests\Core\Plugin\Context\ContextAwarePluginTraitTest::testSetContextValue()
  2. 11.x 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 83

Class

ContextAwarePluginTraitTest
@coversDefaultClass \Drupal\Core\Plugin\ContextAwarePluginTrait

Namespace

Drupal\KernelTests\Core\Plugin\Context

Code

public function testSetContextValue() : void {
    $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);
}

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