protected function setUpNestedExclusiveChoiceSimpleMerge($x = true, $y = true) { $this->workflow = new ezcWorkflow('NestedExclusiveChoiceSimpleMerge'); $setX = new ezcWorkflowNodeVariableSet(array('x' => $x)); $setY = new ezcWorkflowNodeVariableSet(array('y' => $y)); $setZ1 = new ezcWorkflowNodeVariableSet(array('z' => true)); $setZ2 = new ezcWorkflowNodeVariableSet(array('z' => false)); $setZ3 = new ezcWorkflowNodeVariableSet(array('z' => false)); $this->workflow->startNode->addOutNode($setX); $branch1 = new ezcWorkflowNodeExclusiveChoice(); $branch1->addInNode($setX); $branch1->addConditionalOutNode(new ezcWorkflowConditionVariable('x', new ezcWorkflowConditionIsTrue()), $setY); $branch1->addConditionalOutNode(new ezcWorkflowConditionVariable('x', new ezcWorkflowConditionIsFalse()), $setZ3); $branch2 = new ezcWorkflowNodeExclusiveChoice(); $branch2->addInNode($setY); $branch2->addConditionalOutNode(new ezcWorkflowConditionVariable('y', new ezcWorkflowConditionIsTrue()), $setZ1); $branch2->addConditionalOutNode(new ezcWorkflowConditionVariable('y', new ezcWorkflowConditionIsFalse()), $setZ2); $nestedMerge = new ezcWorkflowNodeSimpleMerge(); $nestedMerge->addInNode($setZ1)->addInNode($setZ2); $merge = new ezcWorkflowNodeSimpleMerge(); $merge->addInNode($nestedMerge)->addInNode($setZ3)->addOutNode($this->workflow->endNode); }
// Create an Input node that expects a boolean workflow variable of name "choice". $input = new ezcWorkflowNodeInput(array('choice' => new ezcWorkflowConditionIsBool())); // Add the previously created Input node // as an outgoing node to the start node. $workflow->startNode->addOutNode($input); // Create a new Exclusive Choice node and add it as an // outgoing node to the previously created Input node. // This node will choose which output to run based on the // choice workflow variable. $branch = new ezcWorkflowNodeExclusiveChoice(); $branch->addInNode($input); // Either $true or $false will be run depending on // the above choice. // Note that neither $true nor $false are valid action nodes. // see the next example $trueNode = new ezcWorkflowNodeAction('PrintTrue'); $falseNode = new ezcWorkflowNodeAction('PrintFalse'); // Branch // Condition: Variable "choice" has boolean value "true". // Action: PrintTrue service object. $branch->addConditionalOutNode(new ezcWorkflowConditionVariable('choice', new ezcWorkflowConditionIsTrue()), $trueNode); // Branch // Condition: Variable "choice" has boolean value "false". // Action: PrintFalse service object. $branch->addConditionalOutNode(new ezcWorkflowConditionVariable('choice', new ezcWorkflowConditionIsFalse()), $falseNode); // Create SimpleMerge node and add the two possible threads of // execution as incoming nodes of the end node. $merge = new ezcWorkflowNodeSimpleMerge(); $merge->addInNode($trueNode); $merge->addInNode($falseNode); $merge->addOutNode($workflow->endNode);
public function testForIssue14451() { $this->workflow = new ezcWorkflow('Test'); $this->assertEquals(1, count($this->workflow)); $this->assertEquals(1, count($this->workflow->nodes)); $this->workflow->startNode->addOutNode($this->workflow->endNode); $this->assertEquals(2, count($this->workflow)); $this->assertEquals(2, count($this->workflow->nodes)); $this->workflow->startNode->removeOutNode($this->workflow->endNode); $this->assertEquals(1, count($this->workflow)); $this->assertEquals(1, count($this->workflow->nodes)); $input = new ezcWorkflowNodeInput(array('value' => new ezcWorkflowConditionIsInteger())); $this->workflow->startNode->addOutNode($input); $this->assertEquals(2, count($this->workflow)); $this->assertEquals(2, count($this->workflow->nodes)); $choice = new ezcWorkflowNodeExclusiveChoice(); $input->addOutNode($choice); $this->assertEquals(3, count($this->workflow)); $this->assertEquals(3, count($this->workflow->nodes)); $branch1 = new ezcWorkflowNodeInput(array('value' => new ezcWorkflowConditionIsAnything())); $branch2 = new ezcWorkflowNodeInput(array('value' => new ezcWorkflowConditionIsAnything())); $choice->addConditionalOutNode(new ezcWorkflowConditionIsAnything(), $branch1); $this->assertEquals(4, count($this->workflow)); $this->assertEquals(4, count($this->workflow->nodes)); $choice->addConditionalOutNode(new ezcWorkflowConditionIsAnything(), $branch2); $this->assertEquals(5, count($this->workflow)); $this->assertEquals(5, count($this->workflow->nodes)); $merge = new ezcWorkflowNodeSimpleMerge(); $merge->addInNode($branch1); $merge->addInNode($branch2); $merge->addOutNode($this->workflow->endNode); $this->assertEquals(7, count($this->workflow)); $this->assertEquals(7, count($this->workflow->nodes)); }