function DataConvertTest::testRefiningContextDefinitions

Test that the provided context variable is the correct type.

@covers ::refineContextDefinitions

File

tests/src/Unit/Integration/RulesAction/DataConvertTest.php, line 163

Class

DataConvertTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\DataConvert @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testRefiningContextDefinitions() {
    // Before context refinement, conversion_result data type defaults to 'any'.
    $this->assertEquals('any', $this->action
        ->getProvidedContextDefinition('conversion_result')
        ->getDataType());
    $this->action
        ->setContextValue('target_type', 'date_iso8601');
    $this->action
        ->refineContextDefinitions([]);
    // After context refinement, data type is whatever we set target_type to.
    $this->assertEquals('date_iso8601', $this->action
        ->getProvidedContextDefinition('conversion_result')
        ->getDataType());
}