public function ExpressionSerializationTest::testRuleExpressionSerialization in Rules 8.3
Tests rule serialization.
File
- tests/
src/ Unit/ Integration/ Engine/ ExpressionSerializationTest.php, line 76
Class
- ExpressionSerializationTest
- Tests serializing expression objects.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testRuleExpressionSerialization() {
$expression = $this->rulesExpressionManager
->createRule();
$expression
->addAction('rules_test_string', ContextConfig::create()
->setValue('text', 'test'));
$condition = $this->rulesExpressionManager
->createCondition('rules_test_false');
$condition
->negate(TRUE);
$expression
->addExpressionObject($condition);
$serialized_expression = serialize($expression);
$expression = unserialize($serialized_expression);
$result = RulesComponent::create($expression)
->provideContext('concatenated')
->execute();
$this
->assertSame('testtest', $result['concatenated']);
}