public function DataProcessorTest::testNumericOffset in Rules 8.3
Tests that the numeric offset plugin works.
File
- tests/
src/ Kernel/ DataProcessorTest.php, line 20
Class
- DataProcessorTest
- Test the data processor plugins during Rules evaluation.
Namespace
Drupal\Tests\rules\KernelCode
public function testNumericOffset() {
// Configure a simple rule with one action.
$action = $this->expressionManager
->createInstance('rules_action', ContextConfig::create()
->map('message', 'message')
->map('type', 'type')
->process('message', 'rules_numeric_offset', [
'offset' => 1,
])
->setConfigKey('action_id', 'rules_system_message')
->toArray());
$component = RulesComponent::create($this->expressionManager
->createRule())
->addContextDefinition('message', ContextDefinition::create('string'))
->addContextDefinition('type', ContextDefinition::create('string'))
->setContextValue('message', 1)
->setContextValue('type', 'status');
$component
->getExpression()
->addExpressionObject($action);
$component
->execute();
$messages = $this->messenger
->all();
// The original value was 1 and the processor adds 1, so the result should
// be 2.
$this
->assertEquals((string) $messages[MessengerInterface::TYPE_STATUS][0], '2');
}