You are here

protected function ContextTest::setUpDefaultValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 145
Contains \Drupal\Tests\Core\Plugin\Context\ContextTest.

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
    ->getMock('Drupal\\Core\\TypedData\\DataDefinitionInterface');
  $this->contextDefinition = $this
    ->getMockBuilder('Drupal\\Core\\Plugin\\Context\\ContextDefinitionInterface')
    ->setMethods(array(
    '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
    ->getMock('Drupal\\Core\\TypedData\\TypedDataInterface');
  $this->typedDataManager
    ->expects($this
    ->once())
    ->method('create')
    ->with($mock_data_definition, $default_value)
    ->willReturn($this->typedData);
}