Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $conditions_form_handler = $this->rule->getConditions()->getFormHandler();
     $form = $conditions_form_handler->form($form, $form_state);
     $actions_form_handler = $this->rule->getActions()->getFormHandler();
     $form = $actions_form_handler->form($form, $form_state);
     return $form;
 }
Esempio n. 2
0
 /**
  * Tests that removing expressions by indices works.
  */
 public function testDeletingExpressions()
 {
     // Create a rule with 2 conditions and 2 actions.
     $this->rule->addExpressionObject($this->trueConditionExpression->reveal());
     $this->rule->addExpressionObject($this->falseConditionExpression->reveal());
     $this->rule->addExpressionObject($this->testActionExpression->reveal());
     $second_action = $this->prophesize(RulesAction::class);
     $second_action->getUuid()->willReturn('action_uuid2');
     $this->rule->addExpressionObject($second_action->reveal());
     // Delete the first action.
     $uuid = $this->testActionExpression->reveal()->getUuid();
     $this->rule->deleteExpression($uuid);
     $this->assertEquals(2, count($this->rule->getConditions()->getIterator()));
     $this->assertEquals(1, count($this->rule->getActions()->getIterator()));
     // Delete the second condition.
     $uuid = $this->falseConditionExpression->reveal()->getUuid();
     $this->rule->deleteExpression($uuid);
     $this->assertEquals(1, count($this->rule->getConditions()->getIterator()));
     $this->assertEquals(1, count($this->rule->getActions()->getIterator()));
     // Delete the remaining action.
     $uuid = $second_action->reveal()->getUuid();
     $this->rule->deleteExpression($uuid);
     $this->assertEquals(1, count($this->rule->getConditions()->getIterator()));
     $this->assertEquals(0, count($this->rule->getActions()->getIterator()));
     // Delete the remaining condition, rule should be empty now.
     $uuid = $this->trueConditionExpression->reveal()->getUuid();
     $this->rule->deleteExpression($uuid);
     $this->assertEquals(0, count($this->rule->getConditions()->getIterator()));
     $this->assertEquals(0, count($this->rule->getActions()->getIterator()));
 }
Esempio n. 3
0
 /**
  * Tests the condition container setter and getter.
  *
  * @covers ::setActions
  * @covers ::getActions
  */
 public function testSetActionsGetActions()
 {
     $action_set = new ActionSet([], '', [], $this->expressionManager->reveal());
     $this->rule->setActions($action_set);
     $this->assertSame($action_set, $this->rule->getActions());
 }