Exemplo n.º 1
0
 /**
  * Receive transition by name or object
  *
  * @param string|Transition $transition
  * @return Transition
  * @throws InvalidTransitionException
  */
 public function extractTransition($transition)
 {
     $this->assertTransitionArgument($transition);
     if (is_string($transition)) {
         $transitionName = $transition;
         $transition = $this->getTransition($transitionName);
         if (!$transition) {
             throw InvalidTransitionException::unknownTransition($transitionName);
         }
     }
     return $transition;
 }
 public function isTransitionAllowedDataProvider()
 {
     return array('not_allowed_transition' => array('expectedResult' => false, 'transitionExist' => true, 'transitionAllowed' => false, 'isTransitionStart' => true, 'hasCurrentStep' => true, 'stepAllowTransition' => true), 'allowed_transition' => array('expectedResult' => true, 'transitionExist' => true, 'transitionAllowed' => true, 'isTransitionStart' => true, 'hasCurrentStep' => true, 'stepAllowTransition' => true), 'not_allowed_start_transition' => array('expectedResult' => false, 'transitionExist' => true, 'transitionAllowed' => false, 'isTransitionStart' => false, 'hasCurrentStep' => true, 'stepAllowTransition' => true), 'allowed_start_transition' => array('expectedResult' => true, 'transitionExist' => true, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => true, 'stepAllowTransition' => true), 'unknown_transition_fire_exception' => array('expectedException' => InvalidTransitionException::unknownTransition('test_transition'), 'transitionExist' => false, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => true, 'stepAllowTransition' => true), 'unknown_transition_no_exception' => array('expectedResult' => false, 'transitionExist' => false, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => true, 'stepAllowTransition' => true, 'fireException' => false), 'not_start_transition_fire_exception' => array('expectedException' => InvalidTransitionException::notStartTransition('test_workflow', 'test_transition'), 'transitionExist' => true, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => false, 'stepAllowTransition' => true), 'not_start_transition_no_exception' => array('expectedResult' => false, 'transitionExist' => true, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => false, 'stepAllowTransition' => true, 'fireException' => false), 'step_not_allow_transition_fire_exception' => array('expectedException' => InvalidTransitionException::stepHasNoAllowedTransition('test_workflow', 'test_step', 'test_transition'), 'transitionExist' => true, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => true, 'stepAllowTransition' => false), 'step_not_allow_transition_no_exception' => array('expectedResult' => false, 'transitionExist' => true, 'transitionAllowed' => true, 'isTransitionStart' => false, 'hasCurrentStep' => true, 'stepAllowTransition' => false, 'fireException' => false));
 }
 public function validateExceptionsDataProvider()
 {
     /** @var TransitionIsAllowed $constraint */
     $constraint = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Validator\\Constraints\\TransitionIsAllowed')->disableOriginalConstructor()->getMock();
     return array(array('workflowException' => InvalidTransitionException::unknownTransition('test_transition'), 'expectedViolations' => array(array($constraint->unknownTransitionMessage, array('{{ transition }}' => 'test_transition')))), array('workflowException' => InvalidTransitionException::notStartTransition('test_workflow', 'test_transition'), 'expectedViolations' => array(array($constraint->notStartTransitionMessage, array('{{ transition }}' => 'test_transition')))), array('workflowException' => InvalidTransitionException::stepHasNoAllowedTransition('test_workflow', 'test_step', 'test_transition'), 'expectedViolations' => array(array($constraint->stepHasNotAllowedTransitionMessage, array('{{ transition }}' => 'test_transition', '{{ step }}' => 'test_step')))), array('workflowException' => new InvalidTransitionException(), 'expectedViolations' => array($constraint->someConditionsNotMetMessage)));
 }