function ContextMapperTest::testGetContextValuesContext

Same name in other branches
  1. 4.0.x tests/src/Unit/ContextMapperTest.php \Drupal\Tests\ctools\Unit\ContextMapperTest::testGetContextValuesContext()

@covers ::getContextValues

File

tests/src/Unit/ContextMapperTest.php, line 70

Class

ContextMapperTest
@coversDefaultClass \Drupal\ctools\ContextMapper

Namespace

Drupal\Tests\ctools\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',
            'description' => NULL,
            'type' => 'integer',
            'value' => 5,
        ],
    ];
    $expected = new Context(new ContextDefinition('integer', 'Foo'), 5);
    $actual = $this->staticContext
        ->getContextValues($input)['foo'];
    $this->assertEquals($expected, $actual);
}