function ContextTest::testHasContextValue

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php \Drupal\Tests\Component\Plugin\Context\ContextTest::testHasContextValue()
  2. 11.x 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 104

Class

ContextTest
@coversDefaultClass \Drupal\Component\Plugin\Context\Context @group Plugin

Namespace

Drupal\Tests\Component\Plugin\Context

Code

public function testHasContextValue($has_context_value, $default_value) : void {
    $mock_definition = $this->getMockBuilder('Drupal\\Component\\Plugin\\Context\\ContextDefinitionInterface')
        ->onlyMethods([
        'getDefaultValue',
    ])
        ->getMockForAbstractClass();
    $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.