diff --git a/src/Context/ContextHandlerTrait.php b/src/Context/ContextHandlerTrait.php index e108167f7fa7bad20711bb56b5531c3e8e0b1cef..8d44bf7e7fd33acd313f529bce585d7ce03fb448 100644 --- a/src/Context/ContextHandlerTrait.php +++ b/src/Context/ContextHandlerTrait.php @@ -9,7 +9,7 @@ namespace Drupal\rules\Context; use Drupal\Core\Plugin\Context\Context; use Drupal\Core\Plugin\ContextAwarePluginInterface as CoreContextAwarePluginInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Exception\RulesEvaluationException; /** @@ -34,13 +34,13 @@ trait ContextHandlerTrait { * * @param \Drupal\Core\Plugin\ContextAwarePluginInterface $plugin * The plugin that is populated with context values. - * @param \Drupal\rules\Engine\RulesStateInterface $state + * @param \Drupal\rules\Engine\ExecutionStateInterface $state * The Rules state containing available variables. * * @throws \Drupal\rules\Exception\RulesEvaluationException * In case a required context is missing for the plugin. */ - protected function mapContext(CoreContextAwarePluginInterface $plugin, RulesStateInterface $state) { + protected function mapContext(CoreContextAwarePluginInterface $plugin, ExecutionStateInterface $state) { $context_definitions = $plugin->getContextDefinitions(); foreach ($context_definitions as $name => $definition) { // Check if a data selector is configured that maps to the state. @@ -81,10 +81,10 @@ trait ContextHandlerTrait { * * @param ContextProviderInterface $plugin * The plugin where the context values are extracted. - * @param \Drupal\rules\Engine\RulesStateInterface $state + * @param \Drupal\rules\Engine\ExecutionStateInterface $state * The Rules state where the context variables are added. */ - protected function mapProvidedContext(ContextProviderInterface $plugin, RulesStateInterface $state) { + protected function mapProvidedContext(ContextProviderInterface $plugin, ExecutionStateInterface $state) { $provides = $plugin->getProvidedContextDefinitions(); foreach ($provides as $name => $provided_definition) { // Avoid name collisions in the rules state: provided variables can be @@ -103,10 +103,10 @@ trait ContextHandlerTrait { * * @param \Drupal\Core\Plugin\ContextAwarePluginInterface $plugin * The plugin to process the context data on. - * @param \Drupal\rules\Engine\RulesStateInterface $rules_state + * @param \Drupal\rules\Engine\ExecutionStateInterface $rules_state * The current Rules execution state with context variables. */ - protected function processData(CoreContextAwarePluginInterface $plugin, RulesStateInterface $rules_state) { + protected function processData(CoreContextAwarePluginInterface $plugin, ExecutionStateInterface $rules_state) { if (isset($this->configuration['context_processors'])) { foreach ($this->configuration['context_processors'] as $context_name => $processors) { $value = $plugin->getContextValue($context_name); diff --git a/src/Context/DataProcessorInterface.php b/src/Context/DataProcessorInterface.php index 0c21d7c219a3a55559c75ee0f3bdceb4919e26dd..c8a7d24fa987964812f1651f5f8da1cf54bf11f4 100644 --- a/src/Context/DataProcessorInterface.php +++ b/src/Context/DataProcessorInterface.php @@ -7,7 +7,7 @@ namespace Drupal\rules\Context; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; /** * Interface for Rules data processor plugins. @@ -19,13 +19,13 @@ interface DataProcessorInterface { * * @param mixed $value * The value to process. - * @param \Drupal\rules\Engine\RulesStateInterface $rules_state + * @param \Drupal\rules\Engine\ExecutionStateInterface $rules_state * The current Rules execution state containing all context variables. * * @return mixed * The processed value. Since the value can also be a primitive data type * (a string for example) this function must return the value. */ - public function process($value, RulesStateInterface $rules_state); + public function process($value, ExecutionStateInterface $rules_state); } diff --git a/src/Engine/ConditionExpressionContainer.php b/src/Engine/ConditionExpressionContainer.php index 5e26d91605c6312fc6a7987f9f620ae30493483d..df5c68c70191b0d638aaf9395b3bbb93a69db285 100644 --- a/src/Engine/ConditionExpressionContainer.php +++ b/src/Engine/ConditionExpressionContainer.php @@ -93,7 +93,7 @@ abstract class ConditionExpressionContainer extends ExpressionBase implements Co /** * {@inheritdoc} */ - public function executeWithState(RulesStateInterface $rules_state) { + public function executeWithState(ExecutionStateInterface $rules_state) { $result = $this->evaluate($rules_state); return $this->isNegated() ? !$result : $result; } @@ -101,7 +101,7 @@ abstract class ConditionExpressionContainer extends ExpressionBase implements Co /** * Returns the final result after executing the conditions. */ - abstract public function evaluate(RulesStateInterface $rules_state); + abstract public function evaluate(ExecutionStateInterface $rules_state); /** * {@inheritdoc} diff --git a/src/Engine/RulesState.php b/src/Engine/ExecutionState.php similarity index 97% rename from src/Engine/RulesState.php rename to src/Engine/ExecutionState.php index df48c8ca91d38b5aa5f7a123555e7c0bf20324a0..922261f6fb432ca797904481305276edc7fe5a4f 100644 --- a/src/Engine/RulesState.php +++ b/src/Engine/ExecutionState.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\rules\Engine\RulesState. + * Contains \Drupal\rules\Engine\ExecutionState. */ namespace Drupal\rules\Engine; @@ -18,12 +18,12 @@ use Drupal\rules\Context\ContextDefinitionInterface; use Drupal\rules\Exception\RulesEvaluationException; /** - * The rules evaluation state. + * The rules execution state. * * A rule element may clone the state, so any added variables are only visible * for elements in the current PHP-variable-scope. */ -class RulesState implements RulesStateInterface { +class ExecutionState implements ExecutionStateInterface { use TypedDataTrait; diff --git a/src/Engine/RulesStateInterface.php b/src/Engine/ExecutionStateInterface.php similarity index 97% rename from src/Engine/RulesStateInterface.php rename to src/Engine/ExecutionStateInterface.php index c7e7ccec03d4a8bfd37a606e23db9a260d7bffff..65a8f9e6e722743691494905a7a8460e849dcbf5 100644 --- a/src/Engine/RulesStateInterface.php +++ b/src/Engine/ExecutionStateInterface.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\rules\Engine\RulesStateInterface. + * Contains \Drupal\rules\Engine\ExecutionStateInterface. */ namespace Drupal\rules\Engine; @@ -14,7 +14,7 @@ use Drupal\rules\Context\ContextDefinitionInterface; /** * Defines an interface for the rules state. */ -interface RulesStateInterface { +interface ExecutionStateInterface { /** * Adds a state variable based on its definition and value. diff --git a/src/Engine/ExpressionBase.php b/src/Engine/ExpressionBase.php index 0be8fba67214e971c3c04c586c456808197fd845..314c1ec6ea7b9d5fbbb7747298ae82eca0e84c67 100644 --- a/src/Engine/ExpressionBase.php +++ b/src/Engine/ExpressionBase.php @@ -82,7 +82,7 @@ abstract class ExpressionBase extends PluginBase implements ExpressionInterface */ public function execute() { // If there is no state given, we have to assume no required context. - $state = RulesState::create(); + $state = ExecutionState::create(); $result = $this->executeWithState($state); // Save specifically registered variables in the end after execution. $state->autoSave(); diff --git a/src/Engine/ExpressionInterface.php b/src/Engine/ExpressionInterface.php index 28db725abeae877f323ebd896d509f91fadb5df1..dd4b986911b676d3f38d472ab081e100232f99dc 100644 --- a/src/Engine/ExpressionInterface.php +++ b/src/Engine/ExpressionInterface.php @@ -22,7 +22,7 @@ interface ExpressionInterface extends ExecutableInterface, ConfigurablePluginInt * * Note that this does not auto-save any changes. * - * @param \Drupal\rules\Engine\RulesStateInterface $state + * @param \Drupal\rules\Engine\ExecutionStateInterface $state * The state with all the execution variables in it. * * @return null|bool @@ -32,7 +32,7 @@ interface ExpressionInterface extends ExecutableInterface, ConfigurablePluginInt * @throws \Drupal\rules\Exception\RulesEvaluationException * Thrown if the Rules expression triggers errors during execution. */ - public function executeWithState(RulesStateInterface $state); + public function executeWithState(ExecutionStateInterface $state); /** * Returns the form handling class for this expression. diff --git a/src/Engine/RulesComponent.php b/src/Engine/RulesComponent.php index 223f618a58d00b1d47859e3771ca853be39d59a6..3e510a527458d5e854a611092350ce89197a8bd3 100644 --- a/src/Engine/RulesComponent.php +++ b/src/Engine/RulesComponent.php @@ -17,7 +17,7 @@ class RulesComponent { /** * The rules execution state. * - * @var \Drupal\rules\Engine\RulesStateInterface + * @var \Drupal\rules\Engine\ExecutionStateInterface */ protected $state; @@ -61,7 +61,7 @@ class RulesComponent { * The expression of the component. */ protected function __construct(ExpressionInterface $expression) { - $this->state = RulesState::create(); + $this->state = ExecutionState::create(); $this->expression = $expression; } @@ -78,7 +78,7 @@ class RulesComponent { /** * Gets the execution state. * - * @return \Drupal\rules\Engine\RulesStateInterface + * @return \Drupal\rules\Engine\ExecutionStateInterface * The execution state for this component. */ public function getState() { @@ -189,7 +189,7 @@ class RulesComponent { * Thrown if the Rules expression triggers errors during execution. */ public function executeWithArguments(array $arguments) { - $this->state = RulesState::create(); + $this->state = ExecutionState::create(); foreach ($arguments as $name => $value) { $this->setContextValue($name, $value); } diff --git a/src/EventSubscriber/GenericEventSubscriber.php b/src/EventSubscriber/GenericEventSubscriber.php index 6ebaf70a6a67cfa67e239f49b1b563f363fd4e41..33178a375a1a68ed0a1db49bdde038831910e02b 100644 --- a/src/EventSubscriber/GenericEventSubscriber.php +++ b/src/EventSubscriber/GenericEventSubscriber.php @@ -9,7 +9,7 @@ namespace Drupal\rules\EventSubscriber; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\rules\Engine\RulesEventManager; -use Drupal\rules\Engine\RulesState; +use Drupal\rules\Engine\ExecutionState; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -92,7 +92,7 @@ class GenericEventSubscriber implements EventSubscriberInterface { // Set up an execution state with the event context. $event_definition = $this->eventManager->getDefinition($event_name); - $state = RulesState::create(); + $state = ExecutionState::create(); foreach ($event_definition['context'] as $context_name => $context_definition) { // If this is a GenericEvent get the context for the rule from the event // arguments. diff --git a/src/Plugin/RulesDataProcessor/NumericOffset.php b/src/Plugin/RulesDataProcessor/NumericOffset.php index 1f7800fb19a0d8d45ad5c684def677721f8e14af..434c766c7c3c8cc62b79a186a6468f7575904449 100644 --- a/src/Plugin/RulesDataProcessor/NumericOffset.php +++ b/src/Plugin/RulesDataProcessor/NumericOffset.php @@ -9,7 +9,7 @@ namespace Drupal\rules\Plugin\RulesDataProcessor; use Drupal\Core\Plugin\PluginBase; use Drupal\rules\Context\DataProcessorInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; /** * A data processor for applying numerical offsets. @@ -27,7 +27,7 @@ class NumericOffset extends PluginBase implements DataProcessorInterface { /** * {@inheritdoc} */ - public function process($value, RulesStateInterface $rules_state) { + public function process($value, ExecutionStateInterface $rules_state) { return $value + $this->configuration['offset']; } diff --git a/src/Plugin/RulesDataProcessor/TokenProcessor.php b/src/Plugin/RulesDataProcessor/TokenProcessor.php index 37845379c5bcc3514aee9f0f589736e3d2fe13a6..c31409411f65d05325db03bea38f7fe699906a28 100644 --- a/src/Plugin/RulesDataProcessor/TokenProcessor.php +++ b/src/Plugin/RulesDataProcessor/TokenProcessor.php @@ -12,7 +12,7 @@ use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Utility\Token; use Drupal\rules\Context\DataProcessorInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Exception\RulesEvaluationException; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -65,7 +65,7 @@ class TokenProcessor extends PluginBase implements DataProcessorInterface, Conta /** * {@inheritdoc} */ - public function process($value, RulesStateInterface $rules_state) { + public function process($value, ExecutionStateInterface $rules_state) { $replacements = []; // The Token API requires this metadata object, but it is useless for us // here so we just always pass the same instance and ignore it. diff --git a/src/Plugin/RulesExpression/ActionSet.php b/src/Plugin/RulesExpression/ActionSet.php index b618082a6174f64345cc410e51346b6bf25d3498..b89e82d6d6561dc3d3484835c9011df6b2453b78 100644 --- a/src/Plugin/RulesExpression/ActionSet.php +++ b/src/Plugin/RulesExpression/ActionSet.php @@ -14,7 +14,7 @@ use Drupal\rules\Engine\ActionExpressionContainerInterface; use Drupal\rules\Engine\ActionExpressionInterface; use Drupal\rules\Engine\ExpressionInterface; use Drupal\rules\Engine\ExpressionManagerInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Exception\InvalidExpressionException; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -104,7 +104,7 @@ class ActionSet extends ExpressionBase implements ActionExpressionContainerInter /** * {@inheritdoc} */ - public function executeWithState(RulesStateInterface $state) { + public function executeWithState(ExecutionStateInterface $state) { foreach ($this->actions as $action) { $action->executeWithState($state); } diff --git a/src/Plugin/RulesExpression/Rule.php b/src/Plugin/RulesExpression/Rule.php index 23b5fe9adf2e7c94b8f91b2bcf5577ab3bcb6f4a..43e9141f7307275adf431cf5fbb9149d7c0b3e91 100644 --- a/src/Plugin/RulesExpression/Rule.php +++ b/src/Plugin/RulesExpression/Rule.php @@ -16,7 +16,7 @@ use Drupal\rules\Engine\ConditionExpressionContainerInterface; use Drupal\rules\Engine\ConditionExpressionInterface; use Drupal\rules\Engine\ExpressionInterface; use Drupal\rules\Engine\ExpressionManagerInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Exception\InvalidExpressionException; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -88,7 +88,7 @@ class Rule extends ExpressionBase implements RuleInterface, ContainerFactoryPlug /** * {@inheritdoc} */ - public function executeWithState(RulesStateInterface $state) { + public function executeWithState(ExecutionStateInterface $state) { // Evaluate the rule's conditions. if (!$this->conditions->isEmpty() && !$this->conditions->executeWithState($state)) { // Do not run the actions if the conditions are not met. diff --git a/src/Plugin/RulesExpression/RulesAction.php b/src/Plugin/RulesExpression/RulesAction.php index a807f9ef9ccff65fefe671b650fdacd7f65fc742..085ccb0826a225c0e469622dc8b96d4296df9a9b 100644 --- a/src/Plugin/RulesExpression/RulesAction.php +++ b/src/Plugin/RulesExpression/RulesAction.php @@ -14,7 +14,7 @@ use Drupal\rules\Context\DataProcessorManager; use Drupal\rules\Core\RulesActionManagerInterface; use Drupal\rules\Engine\ActionExpressionInterface; use Drupal\rules\Engine\ExpressionBase; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -88,7 +88,7 @@ class RulesAction extends ExpressionBase implements ContainerFactoryPluginInterf /** * {@inheritdoc} */ - public function executeWithState(RulesStateInterface $state) { + public function executeWithState(ExecutionStateInterface $state) { $action = $this->actionManager->createInstance($this->configuration['action_id']); // We have to forward the context values from our configuration to the diff --git a/src/Plugin/RulesExpression/RulesAnd.php b/src/Plugin/RulesExpression/RulesAnd.php index f89413d118685a7d56748164e25b093a6c71212a..0644410589af540cbe00b45a11167cf5a806ad12 100644 --- a/src/Plugin/RulesExpression/RulesAnd.php +++ b/src/Plugin/RulesExpression/RulesAnd.php @@ -8,7 +8,7 @@ namespace Drupal\rules\Plugin\RulesExpression; use Drupal\rules\Engine\ConditionExpressionContainer; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; /** * Evaluates a group of conditions with a logical AND. @@ -36,7 +36,7 @@ class RulesAnd extends ConditionExpressionContainer { /** * {@inheritdoc} */ - public function evaluate(RulesStateInterface $state) { + public function evaluate(ExecutionStateInterface $state) { foreach ($this->conditions as $condition) { if (!$condition->executeWithState($state)) { return FALSE; diff --git a/src/Plugin/RulesExpression/RulesCondition.php b/src/Plugin/RulesExpression/RulesCondition.php index e4ef29eb7903825a41b45fbb13cea7899301b23c..d38a097eb8d83877c86c5aed09b642088b0db990 100644 --- a/src/Plugin/RulesExpression/RulesCondition.php +++ b/src/Plugin/RulesExpression/RulesCondition.php @@ -13,7 +13,7 @@ use Drupal\rules\Context\ContextHandlerTrait; use Drupal\rules\Context\DataProcessorManager; use Drupal\rules\Engine\ConditionExpressionInterface; use Drupal\rules\Engine\ExpressionBase; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -101,7 +101,7 @@ class RulesCondition extends ExpressionBase implements ConditionExpressionInterf /** * {@inheritdoc} */ - public function executeWithState(RulesStateInterface $state) { + public function executeWithState(ExecutionStateInterface $state) { $condition = $this->conditionManager->createInstance($this->configuration['condition_id'], [ 'negate' => $this->configuration['negate'], ]); diff --git a/src/Plugin/RulesExpression/RulesOr.php b/src/Plugin/RulesExpression/RulesOr.php index ef181c4a7a58f6c41f89fcd6597ce237e6176419..bc740109d96014f568c1df6c0315aa7df29ac695 100644 --- a/src/Plugin/RulesExpression/RulesOr.php +++ b/src/Plugin/RulesExpression/RulesOr.php @@ -8,7 +8,7 @@ namespace Drupal\rules\Plugin\RulesExpression; use Drupal\rules\Engine\ConditionExpressionContainer; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; /** * Evaluates a group of conditions with a logical OR. @@ -23,7 +23,7 @@ class RulesOr extends ConditionExpressionContainer { /** * {@inheritdoc} */ - public function evaluate(RulesStateInterface $state) { + public function evaluate(ExecutionStateInterface $state) { foreach ($this->conditions as $condition) { if ($condition->executeWithState($state)) { return TRUE; diff --git a/tests/src/Integration/Engine/RulesComponentTest.php b/tests/src/Integration/Engine/RulesComponentTest.php index 79765577cfb04ef727de05172d0104be3091d706..b5ce64479913ec04b11eac1d11766b28059d17e9 100644 --- a/tests/src/Integration/Engine/RulesComponentTest.php +++ b/tests/src/Integration/Engine/RulesComponentTest.php @@ -10,7 +10,7 @@ namespace Drupal\Tests\rules\Integration\Engine; use Drupal\rules\Context\ContextConfig; use Drupal\rules\Context\ContextDefinition; use Drupal\rules\Engine\RulesComponent; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\Tests\rules\Integration\RulesIntegrationTestBase; /** @@ -80,7 +80,7 @@ class RulesComponentTest extends RulesIntegrationTestBase { public function testGetState() { $rule = $this->rulesExpressionManager->createRule(); $component = RulesComponent::create($rule); - $this->assertInstanceOf(RulesStateInterface::class, $component->getState()); + $this->assertInstanceOf(ExecutionStateInterface::class, $component->getState()); // Test that set context values are available in the state. $component diff --git a/tests/src/Kernel/RulesEngineTest.php b/tests/src/Kernel/RulesEngineTest.php index 21283f3a49b72685f9dd02092b81be688ff8da0f..50d1a3e76f543cb496b4c39cad72200e86ac81e8 100644 --- a/tests/src/Kernel/RulesEngineTest.php +++ b/tests/src/Kernel/RulesEngineTest.php @@ -10,7 +10,7 @@ namespace Drupal\Tests\rules\Kernel; use Drupal\rules\Context\ContextConfig; use Drupal\rules\Context\ContextDefinition; use Drupal\rules\Engine\RulesComponent; -use Drupal\rules\Engine\RulesState; +use Drupal\rules\Engine\ExecutionState; /** * Test using the Rules API to create and evaluate rules. @@ -111,7 +111,7 @@ class RulesEngineTest extends RulesDrupalTestBase { ->provideAs('provided_text', 'newname') ); - $state = RulesState::create(); + $state = ExecutionState::create(); $rule->executeWithState($state); // Check that the newly named variable exists and has the provided value. @@ -141,7 +141,7 @@ class RulesEngineTest extends RulesDrupalTestBase { ->provideAs('concatenated', 'concatenated2') ); - $state = RulesState::create(); + $state = ExecutionState::create(); $rule->executeWithState($state); // Check that the created variables exists and have the provided values. diff --git a/tests/src/Unit/ActionSetTest.php b/tests/src/Unit/ActionSetTest.php index bbde48f27ddeee1de79dea3402ef1a61f6f8f668..e94d43e554a7c5dcc358e4ab6ac58228b8b91713 100644 --- a/tests/src/Unit/ActionSetTest.php +++ b/tests/src/Unit/ActionSetTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\rules\Unit; use Drupal\rules\Plugin\RulesExpression\ActionSet; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Prophecy\Argument; /** @@ -39,7 +39,7 @@ class ActionSetTest extends RulesUnitTestBase { public function testActionExecution() { // The method on the test action must be called once. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->actionSet->addExpressionObject($this->testActionExpression->reveal())->execute(); } @@ -50,7 +50,7 @@ class ActionSetTest extends RulesUnitTestBase { public function testTwoActionExecution() { // The method on the test action must be called twice. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(2); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(2); $this->actionSet->addExpressionObject($this->testActionExpression->reveal()) ->addExpressionObject($this->testActionExpression->reveal()) @@ -63,7 +63,7 @@ class ActionSetTest extends RulesUnitTestBase { public function testNestedActionExecution() { // The method on the test action must be called twice. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(2); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(2); $inner = new ActionSet([], '', [], $this->expressionManager->reveal()); $inner->addExpressionObject($this->testActionExpression->reveal()); diff --git a/tests/src/Unit/ContextHandlerTraitTest.php b/tests/src/Unit/ContextHandlerTraitTest.php index 15cd22da58adf5e8c40e5d776fcfe79535d8818b..442c6c36a713a0dc2385f7e078533989f1b2661f 100644 --- a/tests/src/Unit/ContextHandlerTraitTest.php +++ b/tests/src/Unit/ContextHandlerTraitTest.php @@ -11,7 +11,7 @@ use Drupal\Core\Plugin\ContextAwarePluginInterface; use Drupal\rules\Context\ContextConfig; use Drupal\rules\Context\ContextDefinitionInterface; use Drupal\rules\Context\ContextHandlerTrait; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; /** * @coversDefaultClass \Drupal\rules\Context\ContextHandlerTrait @@ -45,7 +45,7 @@ class ContextHandlerTraitTest extends RulesUnitTestBase { ->shouldBeCalled(1); $plugin->getPluginId()->willReturn('testplugin')->shouldBeCalledTimes(1); - $state = $this->prophesize(RulesStateInterface::class); + $state = $this->prophesize(ExecutionStateInterface::class); // Make the 'mapContext' method visible. $reflection = new \ReflectionClass($trait); diff --git a/tests/src/Unit/RuleTest.php b/tests/src/Unit/RuleTest.php index e6c481b5e87ff909f8252e731e924bede451e2f6..a953fbf6a3703ca19b8550be938b8abe057b81aa 100644 --- a/tests/src/Unit/RuleTest.php +++ b/tests/src/Unit/RuleTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\rules\Unit; use Drupal\rules\Engine\ExpressionManagerInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Plugin\RulesExpression\Rule; use Drupal\rules\Plugin\RulesExpression\RulesAnd; use Drupal\rules\Plugin\RulesExpression\RulesOr; @@ -112,7 +112,7 @@ class RuleTest extends RulesUnitTestBase { public function testActionExecution() { // The method on the test action must be called once. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->rule ->addExpressionObject($this->trueConditionExpression->reveal()) @@ -128,7 +128,7 @@ class RuleTest extends RulesUnitTestBase { public function testConditionFails() { // The execute method on the action must never be called. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldNotBeCalled(); + Argument::type(ExecutionStateInterface::class))->shouldNotBeCalled(); $this->rule ->addExpressionObject($this->falseConditionExpression->reveal()) @@ -144,7 +144,7 @@ class RuleTest extends RulesUnitTestBase { public function testTwoConditionsTrue() { // The method on the test action must be called once. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->rule ->addExpressionObject($this->trueConditionExpression->reveal()) @@ -161,7 +161,7 @@ class RuleTest extends RulesUnitTestBase { public function testTwoConditionsFalse() { // The execute method on the action must never be called. $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldNotBeCalled(); + Argument::type(ExecutionStateInterface::class))->shouldNotBeCalled(); $this->rule ->addExpressionObject($this->trueConditionExpression->reveal()) @@ -177,7 +177,7 @@ class RuleTest extends RulesUnitTestBase { */ public function testNestedRules() { $this->testActionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $nested = new Rule([], 'rules_rule', [], $this->expressionManager->reveal()); // We need to replace the action and conditon container to not have the same diff --git a/tests/src/Unit/RulesAndTest.php b/tests/src/Unit/RulesAndTest.php index d4c0d53685734137c48a01bef25f110def9ef017..e5a02ce5438e983655db19c7fcffda507fe978cc 100644 --- a/tests/src/Unit/RulesAndTest.php +++ b/tests/src/Unit/RulesAndTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\rules\Unit; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Plugin\RulesExpression\RulesAnd; use Prophecy\Argument; @@ -39,7 +39,7 @@ class RulesAndTest extends RulesUnitTestBase { public function testOneCondition() { // The method on the test condition must be called once. $this->trueConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->and->addExpressionObject($this->trueConditionExpression->reveal()); $this->assertTrue($this->and->execute(), 'Single condition returns TRUE.'); } @@ -61,7 +61,7 @@ class RulesAndTest extends RulesUnitTestBase { public function testTwoConditions() { // The method on the test condition must be called twice. $this->trueConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(2); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(2); $this->and ->addExpressionObject($this->trueConditionExpression->reveal()) @@ -76,7 +76,7 @@ class RulesAndTest extends RulesUnitTestBase { public function testTwoFalseConditions() { // The method on the test condition must be called once. $this->falseConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->and ->addExpressionObject($this->falseConditionExpression->reveal()) diff --git a/tests/src/Unit/RulesConditionContainerTest.php b/tests/src/Unit/RulesConditionContainerTest.php index 6b8595ee3368f2911495651da43accf238e39785..d7411f1c6e73da98440e7fb3bcd232426f931275 100644 --- a/tests/src/Unit/RulesConditionContainerTest.php +++ b/tests/src/Unit/RulesConditionContainerTest.php @@ -8,7 +8,7 @@ namespace Drupal\Tests\rules\Unit; use Drupal\rules\Engine\ConditionExpressionContainer; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; /** * @coversDefaultClass \Drupal\rules\Engine\ConditionExpressionContainer @@ -85,7 +85,7 @@ abstract class RulesConditionContainerTestStub extends ConditionExpressionContai /** * {@inheritdoc} */ - public function evaluate(RulesStateInterface $state) { + public function evaluate(ExecutionStateInterface $state) { return TRUE; } diff --git a/tests/src/Unit/RulesConditionTest.php b/tests/src/Unit/RulesConditionTest.php index 33d6c91e5ca9d53694a238c99f82783adb15c1f5..262b8fb6cb2168e54ca2d23cd224290666e2094c 100644 --- a/tests/src/Unit/RulesConditionTest.php +++ b/tests/src/Unit/RulesConditionTest.php @@ -12,7 +12,7 @@ use Drupal\Core\Plugin\Context\ContextDefinitionInterface; use Drupal\rules\Context\DataProcessorInterface; use Drupal\rules\Context\ContextConfig; use Drupal\rules\Context\DataProcessorManager; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Plugin\RulesExpression\RulesCondition; use Drupal\rules\Core\RulesConditionInterface; use Drupal\Tests\UnitTestCase; @@ -133,7 +133,7 @@ class RulesConditionTest extends UnitTestCase { ->shouldBeCalledTimes(1); // Build some mocked execution state. - $state = $this->prophesize(RulesStateInterface::class); + $state = $this->prophesize(ExecutionStateInterface::class); $prophecy = $state->getVariable('test'); /** @var \Prophecy\Prophecy\MethodProphecy $prophecy */ $prophecy->willReturn('old_value'); diff --git a/tests/src/Unit/RulesOrTest.php b/tests/src/Unit/RulesOrTest.php index 2fd06795c3065cf88e1403f22d02076543e39854..ee0a2df365bc39baf3cdb6496925e5f0f9e727f2 100644 --- a/tests/src/Unit/RulesOrTest.php +++ b/tests/src/Unit/RulesOrTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\rules\Unit; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Plugin\RulesExpression\RulesOr; use Prophecy\Argument; @@ -39,7 +39,7 @@ class RulesOrTest extends RulesUnitTestBase { public function testOneCondition() { // The method on the test condition must be called once. $this->trueConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->or->addExpressionObject($this->trueConditionExpression->reveal()); $this->assertTrue($this->or->execute(), 'Single condition returns TRUE.'); @@ -62,7 +62,7 @@ class RulesOrTest extends RulesUnitTestBase { public function testTwoConditions() { // The method on the test condition must be called once. $this->trueConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $this->or ->addExpressionObject($this->trueConditionExpression->reveal()) @@ -77,7 +77,7 @@ class RulesOrTest extends RulesUnitTestBase { public function testTwoFalseConditions() { // The method on the test condition must be called twice. $this->falseConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(2); + Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(2); $this->or ->addExpressionObject($this->falseConditionExpression->reveal()) diff --git a/tests/src/Unit/RulesUnitTestBase.php b/tests/src/Unit/RulesUnitTestBase.php index 302c60638eb35b07b68657a265ff4b0d0f5d6ecd..e01f9f4e8a5c8930d29df2dd63a3067b3ac8b097 100644 --- a/tests/src/Unit/RulesUnitTestBase.php +++ b/tests/src/Unit/RulesUnitTestBase.php @@ -9,7 +9,7 @@ namespace Drupal\Tests\rules\Unit; use Drupal\rules\Engine\ActionExpressionInterface; use Drupal\rules\Engine\ConditionExpressionInterface; -use Drupal\rules\Engine\RulesStateInterface; +use Drupal\rules\Engine\ExecutionStateInterface; use Drupal\rules\Engine\ExpressionManagerInterface; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; @@ -57,12 +57,12 @@ abstract class RulesUnitTestBase extends UnitTestCase { $this->trueConditionExpression->execute()->willReturn(TRUE); $this->trueConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->willReturn(TRUE); + Argument::type(ExecutionStateInterface::class))->willReturn(TRUE); $this->falseConditionExpression = $this->prophesize(ConditionExpressionInterface::class); $this->falseConditionExpression->execute()->willReturn(FALSE); $this->falseConditionExpression->executeWithState( - Argument::type(RulesStateInterface::class))->willReturn(FALSE); + Argument::type(ExecutionStateInterface::class))->willReturn(FALSE); $this->testActionExpression = $this->prophesize(ActionExpressionInterface::class);