From 460865a2f036c31902e94e10c01e589fda886089 Mon Sep 17 00:00:00 2001 From: Wolfgang Ziegler // fago <fago@wolfgangziegler.net> Date: Thu, 10 Dec 2015 14:57:28 +0100 Subject: [PATCH] Issue #2632516: Rename RulesState and its interface to ExecutionState. --- src/Context/ContextHandlerTrait.php | 14 +++++++------- src/Context/DataProcessorInterface.php | 6 +++--- src/Engine/ConditionExpressionContainer.php | 4 ++-- src/Engine/{RulesState.php => ExecutionState.php} | 6 +++--- ...teInterface.php => ExecutionStateInterface.php} | 4 ++-- src/Engine/ExpressionBase.php | 2 +- src/Engine/ExpressionInterface.php | 4 ++-- src/Engine/RulesComponent.php | 8 ++++---- src/EventSubscriber/GenericEventSubscriber.php | 4 ++-- src/Plugin/RulesDataProcessor/NumericOffset.php | 4 ++-- src/Plugin/RulesDataProcessor/TokenProcessor.php | 4 ++-- src/Plugin/RulesExpression/ActionSet.php | 4 ++-- src/Plugin/RulesExpression/Rule.php | 4 ++-- src/Plugin/RulesExpression/RulesAction.php | 4 ++-- src/Plugin/RulesExpression/RulesAnd.php | 4 ++-- src/Plugin/RulesExpression/RulesCondition.php | 4 ++-- src/Plugin/RulesExpression/RulesOr.php | 4 ++-- .../src/Integration/Engine/RulesComponentTest.php | 4 ++-- tests/src/Kernel/RulesEngineTest.php | 6 +++--- tests/src/Unit/ActionSetTest.php | 8 ++++---- tests/src/Unit/ContextHandlerTraitTest.php | 4 ++-- tests/src/Unit/RuleTest.php | 12 ++++++------ tests/src/Unit/RulesAndTest.php | 8 ++++---- tests/src/Unit/RulesConditionContainerTest.php | 4 ++-- tests/src/Unit/RulesConditionTest.php | 4 ++-- tests/src/Unit/RulesOrTest.php | 8 ++++---- tests/src/Unit/RulesUnitTestBase.php | 6 +++--- 27 files changed, 74 insertions(+), 74 deletions(-) rename src/Engine/{RulesState.php => ExecutionState.php} (97%) rename src/Engine/{RulesStateInterface.php => ExecutionStateInterface.php} (97%) diff --git a/src/Context/ContextHandlerTrait.php b/src/Context/ContextHandlerTrait.php index e108167f..8d44bf7e 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 0c21d7c2..c8a7d24f 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 5e26d916..df5c68c7 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 df48c8ca..922261f6 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 c7e7ccec..65a8f9e6 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 0be8fba6..314c1ec6 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 28db725a..dd4b9869 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 223f618a..3e510a52 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 6ebaf70a..33178a37 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 1f7800fb..434c766c 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 37845379..c3140941 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 b618082a..b89e82d6 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 23b5fe9a..43e9141f 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 a807f9ef..085ccb08 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 f89413d1..06444105 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 e4ef29eb..d38a097e 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 ef181c4a..bc740109 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 79765577..b5ce6447 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 21283f3a..50d1a3e7 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 bbde48f2..e94d43e5 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 15cd22da..442c6c36 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 e6c481b5..a953fbf6 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 d4c0d536..e5a02ce5 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 6b8595ee..d7411f1c 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 33d6c91e..262b8fb6 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 2fd06795..ee0a2df3 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 302c6063..e01f9f4e 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); -- GitLab