function ContextTest::setUpDefaultValue

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php \Drupal\Tests\Core\Plugin\Context\ContextTest::setUpDefaultValue()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php \Drupal\Tests\Core\Plugin\Context\ContextTest::setUpDefaultValue()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php \Drupal\Tests\Core\Plugin\Context\ContextTest::setUpDefaultValue()

Set up mocks for the getDefaultValue() method call.

Parameters

mixed $default_value: The default value to assign to the mock context definition.

3 calls to ContextTest::setUpDefaultValue()
ContextTest::testDefaultDataValue in core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@covers ::getContextData
ContextTest::testDefaultValue in core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@covers ::getContextValue
ContextTest::testNullDataValue in core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@covers ::getContextData

File

core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php, line 144

Class

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

Namespace

Drupal\Tests\Core\Plugin\Context

Code

protected function setUpDefaultValue($default_value = NULL) {
    $mock_data_definition = $this->createMock('Drupal\\Core\\TypedData\\DataDefinitionInterface');
    $this->contextDefinition = $this->getMockBuilder('Drupal\\Core\\Plugin\\Context\\ContextDefinitionInterface')
        ->onlyMethods([
        'getDefaultValue',
        'getDataDefinition',
    ])
        ->getMockForAbstractClass();
    $this->contextDefinition
        ->expects($this->once())
        ->method('getDefaultValue')
        ->willReturn($default_value);
    $this->contextDefinition
        ->expects($this->once())
        ->method('getDataDefinition')
        ->willReturn($mock_data_definition);
    $this->typedData = $this->createMock('Drupal\\Core\\TypedData\\TypedDataInterface');
    $this->typedDataManager
        ->expects($this->once())
        ->method('create')
        ->with($mock_data_definition, $default_value)
        ->willReturn($this->typedData);
}

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