/** * Tests that nested rules are properly executed. * * @covers ::execute */ public function testNestedRules() { $this->testActionExpression->executeWithState(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 // instances as in the outer rule. $nested->setConditions(new RulesAnd([], 'rules_and', [], $this->expressionManager->reveal())); $nested->setActions(new ActionSet([], 'rules_action_set', [], $this->expressionManager->reveal())); $nested->addExpressionObject($this->trueConditionExpression->reveal())->addExpressionObject($this->testActionExpression->reveal()); $this->rule->addExpressionObject($this->trueConditionExpression->reveal())->addExpressionObject($nested)->execute(); }
/** * Tests that provided context definitons are created from configuration. */ public function testProvidedDefinitionFromConfig() { $rule = new Rule(['provided_definitions' => ['node' => ContextDefinition::create('entity:node')->setLabel('node')->toArray()]], 'rules_rule', [], $this->expressionManager->reveal()); $provided_definition = $rule->getProvidedContextDefinition('node'); $this->assertSame($provided_definition->getDataType(), 'entity:node'); }