You are here

public function ContextMapperTest::testGetContextValuesContext in Page Manager 8

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/ContextMapperTest.php \Drupal\Tests\page_manager\Unit\ContextMapperTest::testGetContextValuesContext()

@covers ::getContextValues

File

tests/src/Unit/ContextMapperTest.php, line 72
Contains \Drupal\Tests\page_manager\Unit\ContextMapperTest.

Class

ContextMapperTest
@coversDefaultClass \Drupal\page_manager\ContextMapper

Namespace

Drupal\Tests\page_manager\Unit

Code

public function testGetContextValuesContext() {
  $data_definition = DataDefinition::createFromDataType('integer');
  $typed_data = IntegerData::createInstance($data_definition);
  $this->typedDataManager
    ->createDataDefinition('integer')
    ->willReturn($data_definition);
  $this->typedDataManager
    ->getDefaultConstraints($data_definition)
    ->willReturn([]);
  $this->typedDataManager
    ->create($data_definition, 5)
    ->willReturn($typed_data);
  $input = [
    'foo' => [
      'label' => 'Foo',
      'type' => 'integer',
      'value' => 5,
    ],
  ];
  $expected = new Context(new ContextDefinition('integer', 'Foo'), 5);
  $actual = $this->staticContext
    ->getContextValues($input)['foo'];
  $this
    ->assertEquals($expected, $actual);
}