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. 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[[api-linebreak]]
ContextTest::testDefaultValue in core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@covers ::getContextValue[[api-linebreak]]
ContextTest::testNullDataValue in core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@covers ::getContextData[[api-linebreak]]

File

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

Class

ContextTest
@coversDefaultClass \Drupal\Core\Plugin\Context\Context[[api-linebreak]] @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.