You are here

protected function ContextTest::setUpDefaultValue in Drupal 10

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

File

core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php, line 144
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
    ->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);
}