function RulesComponentTest::testGetState

@covers ::getState

File

tests/src/Unit/Integration/Engine/RulesComponentTest.php, line 76

Class

RulesComponentTest
Tests the Rules component class.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testGetState() {
    $rule = $this->rulesExpressionManager
        ->createRule();
    $component = RulesComponent::create($rule);
    $this->assertInstanceOf(ExecutionStateInterface::class, $component->getState());
    // Test that set context values are available in the state.
    $component->addContextDefinition('foo', ContextDefinition::create('string'))
        ->setContextValue('foo', 'bar');
    $this->assertEquals($component->getState()
        ->getVariableValue('foo'), 'bar');
}