function ContextTest::setUpDefaultValue

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php \Drupal\Tests\Core\Plugin\Context\ContextTest::setUpDefaultValue()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php \Drupal\Tests\Core\Plugin\Context\ContextTest::setUpDefaultValue()
  3. 10 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 139

Class

ContextTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21Context%21Context.php/class/Context/11.x" title="A Drupal specific context wrapper class." class="local">\Drupal\Core\Plugin\Context\Context</a> @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->createMock('Drupal\\Core\\Plugin\\Context\\ContextDefinitionInterface');
    $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.