/** * Tests two false conditions. */ public function testTwoFalseConditions() { // The method on the test condition must be called once. $this->falseConditionExpression->executeWithState(Argument::type(RulesStateInterface::class))->shouldBeCalledTimes(1); $this->and->addExpressionObject($this->falseConditionExpression->reveal())->addExpressionObject($this->falseConditionExpression->reveal()); $this->assertFalse($this->and->execute(), 'Two false conditions return FALSE.'); }
/** * Tests two false conditions. */ public function testTwoFalseConditions() { $this->falseConditionExpression->executeWithState(Argument::type(ExecutionStateInterface::class))->shouldBeCalledTimes(1); $second_condition = $this->prophesize(ConditionExpressionInterface::class); $second_condition->getUuid()->willReturn('false_uuid2'); $second_condition->executeWithState(Argument::type(ExecutionStateInterface::class))->willReturn(FALSE)->shouldBeCalledTimes(1); $this->or->addExpressionObject($this->falseConditionExpression->reveal())->addExpressionObject($second_condition->reveal()); $this->assertFalse($this->or->execute(), 'Two false conditions return FALSE.'); }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form['conditions'] = ['#type' => 'container']; $form['conditions']['table'] = ['#theme' => 'table', '#caption' => $this->t('Conditions'), '#header' => [$this->t('Elements'), $this->t('Operations')], '#empty' => t('None')]; foreach ($this->conditionContainer as $uuid => $condition) { $form['conditions']['table']['#rows'][] = ['element' => $condition->getLabel(), 'operations' => ['data' => ['#type' => 'dropbutton', '#links' => ['edit' => ['title' => $this->t('Edit'), 'url' => Url::fromRoute('rules.reaction_rule.expression.edit', ['reaction_config' => $this->conditionContainer->getRoot()->getConfigEntityId(), 'uuid' => $uuid])], 'delete' => ['title' => $this->t('Delete'), 'url' => Url::fromRoute('rules.reaction_rule.expression.delete', ['rules_reaction_rule' => $this->conditionContainer->getRoot()->getConfigEntityId(), 'uuid' => $uuid])]]]]]; } // @todo Put this into the table as last row and style it like it was in // Drupal 7 Rules. $form['add_condition'] = ['#theme' => 'menu_local_action', '#link' => ['title' => $this->t('Add condition'), 'url' => Url::fromRoute('rules.reaction_rule.expression.add', ['reaction_config' => $this->conditionContainer->getRoot()->getConfigEntityId(), 'expression_id' => 'rules_condition'])]]; return $form; }
/** * PHP magic __clone function. */ public function __clone() { $this->actions = clone $this->actions; $this->actions->setRoot($this->getRoot()); $this->conditions = clone $this->conditions; $this->conditions->setRoot($this->getRoot()); }
/** * {@inheritdoc} */ public function getConfiguration() { $configuration = parent::getConfiguration(); // We need to update the configuration in case actions/conditions have been // added or changed. $configuration['conditions'] = $this->conditions->getConfiguration(); $configuration['actions'] = $this->actions->getConfiguration(); return $configuration; }
/** * {@inheritdoc} */ public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state) { $violation_list = $this->conditions->checkIntegrity($metadata_state); $violation_list->addAll($this->actions->checkIntegrity($metadata_state)); return $violation_list; }