function ContextTest::testHasContextValue

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php \Drupal\Tests\Component\Plugin\Context\ContextTest::testHasContextValue()
  2. 10 core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php \Drupal\Tests\Component\Plugin\Context\ContextTest::testHasContextValue()

@covers ::hasContextValue @dataProvider providerHasContextValue

File

core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php, line 103

Class

ContextTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Plugin%21Context%21Context.php/class/Context/11.x" title="A generic context class for wrapping data a plugin needs to operate." class="local">\Drupal\Component\Plugin\Context\Context</a> @group Plugin

Namespace

Drupal\Tests\Component\Plugin\Context

Code

public function testHasContextValue($has_context_value, $default_value) : void {
    $mock_definition = $this->createMock('Drupal\\Component\\Plugin\\Context\\ContextDefinitionInterface');
    $mock_definition->expects($this->atLeastOnce())
        ->method('getDefaultValue')
        ->willReturn($default_value);
    $context = new Context($mock_definition);
    $this->assertSame($has_context_value, $context->hasContextValue());
    $this->assertSame($default_value, $context->getContextValue());
}

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