/** * {@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; }
/** * Tests the condition container setter and getter. * * @covers ::setConditions * @covers ::getConditions */ public function testSetConditionsGetConditions() { $or = new RulesOr([], 'rules_or', [], $this->expressionManager->reveal()); $this->rule->setConditions($or); $this->assertSame($or, $this->rule->getConditions()); $and = new RulesAnd([], 'rules_and', [], $this->expressionManager->reveal()); $this->rule->setConditions($and); $this->assertSame($and, $this->rule->getConditions()); }
/** * 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())); }