You are here

public function RulesComponentTest::testGetState in Rules 8.3

@covers ::getState

File

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

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