Example #1
0
 /**
  * @dataProvider transitDataProvider
  * @param boolean $isFinal
  * @param boolean $hasAllowedTransition
  */
 public function testTransit($isFinal, $hasAllowedTransition)
 {
     $currentStepEntity = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowStep')->disableOriginalConstructor()->getMock();
     $step = $this->getStepMock('currentStep', $isFinal, $hasAllowedTransition, $currentStepEntity);
     $workflowDefinition = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowDefinition')->disableOriginalConstructor()->getMock();
     $workflowDefinition->expects($this->once())->method('getStepByName')->with($step->getName())->will($this->returnValue($currentStepEntity));
     $workflowItem = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowItem')->disableOriginalConstructor()->getMock();
     $workflowItem->expects($this->once())->method('getDefinition')->will($this->returnValue($workflowDefinition));
     $workflowItem->expects($this->once())->method('setCurrentStep')->with($currentStepEntity);
     $preCondition = $this->getMock('Oro\\Bundle\\WorkflowBundle\\Model\\Condition\\ConditionInterface');
     $preCondition->expects($this->once())->method('isAllowed')->with($workflowItem)->will($this->returnValue(true));
     $condition = $this->getMock('Oro\\Bundle\\WorkflowBundle\\Model\\Condition\\ConditionInterface');
     $condition->expects($this->once())->method('isAllowed')->with($workflowItem)->will($this->returnValue(true));
     $postAction = $this->getMock('Oro\\Bundle\\WorkflowBundle\\Model\\Action\\ActionInterface');
     $postAction->expects($this->once())->method('execute')->with($workflowItem);
     $obj = new Transition();
     $obj->setPreCondition($preCondition);
     $obj->setCondition($condition);
     $obj->setPostAction($postAction);
     $obj->setStepTo($step);
     $obj->transit($workflowItem);
 }