function VariableAddTest::testExecute

Test the action execution.

@covers ::execute

File

tests/src/Unit/Integration/RulesAction/VariableAddTest.php, line 18

Class

VariableAddTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\VariableAdd @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testExecute() {
    $variable = 'test string';
    
    /** @var \Drupal\rules\Plugin\RulesAction\VariableAdd $action */
    $action = $this->actionManager
        ->createInstance('rules_variable_add');
    $action->setContextValue('type', 'string');
    $action->setContextValue('value', $variable);
    $action->refineContextDefinitions([]);
    $action->execute();
    $result = $action->getProvidedContext('variable_added');
    $this->assertEquals($variable, $result->getContextValue());
    $this->assertEquals('string', $result->getContextDefinition()
        ->getDataType());
}