function ContextMapperTest::testGetContextValuesContext

Same name and namespace 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 <a href="/api/ctools/src%21ContextMapper.php/class/ContextMapper/8.x-3.x" title="Maps context configurations to context objects." class="local">\Drupal\ctools\ContextMapper</a>

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);
}