DataProcessorTest.php in Rules 8.3
File
tests/src/Kernel/DataProcessorTest.php
View source
<?php
namespace Drupal\Tests\rules\Kernel;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\rules\Context\ContextDefinition;
use Drupal\rules\Context\ContextConfig;
use Drupal\rules\Engine\RulesComponent;
class DataProcessorTest extends RulesKernelTestBase {
public function testNumericOffset() {
$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();
$this
->assertEquals((string) $messages[MessengerInterface::TYPE_STATUS][0], '2');
}
}