VariableAddTest.php

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

File

tests/src/Unit/Integration/RulesAction/VariableAddTest.php

View source
<?php

namespace Drupal\Tests\rules\Unit\Integration\RulesAction;

use Drupal\Tests\rules\Unit\Integration\RulesIntegrationTestBase;

/**
 * @coversDefaultClass \Drupal\rules\Plugin\RulesAction\VariableAdd
 * @group RulesAction
 */
class VariableAddTest extends RulesIntegrationTestBase {
    
    /**
     * Test the action execution.
     *
     * @covers ::execute
     */
    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());
    }

}

Classes

Title Deprecated Summary
VariableAddTest @coversDefaultClass \Drupal\rules\Plugin\RulesAction\VariableAdd @group RulesAction