/**
  * {@inheritdoc}
  */
 public function getTransition()
 {
     if ($this->isWorkflowStarted()) {
         return $this->workflow->getTransition($this->transitionName);
     }
     return $this->workflow->getStartTransition();
 }
 function let(Item $item, Workflow $workflow, StateRepository $stateRepository, EntityRepository $entityRepository, TransactionHandler $transactionHandler, SymfonyEventDispatcher $eventDispatcher, Transition $transition, State $state, EntityId $entityId, Step $step)
 {
     $workflow->getStep(static::STEP_NAME)->willReturn($step);
     $workflow->getStartTransition()->willReturn($transition);
     $workflow->getName()->willReturn(static::WORKFLOW_NAME);
     $step->isTransitionAllowed(static::TRANSITION_NAME)->willReturn(true);
     $workflow->getTransition(static::TRANSITION_NAME)->willReturn($transition);
     $transition->getName()->willReturn(static::TRANSITION_NAME);
     $transition->isInputRequired($item)->willReturn(false);
     $item->transit($transition, Argument::type(static::CONTEXT_CLASS), Argument::type(static::ERROR_COLLECTION_CLASS), true)->willReturn($state);
     $item->isWorkflowStarted()->willReturn(true);
     $item->getCurrentStepName()->willReturn(static::STEP_NAME);
     $item->getEntity()->willReturn(static::$entity);
     $entityId->__toString()->willReturn('entity::2');
     $this->beConstructedWith($eventDispatcher);
 }
 function it_gets_transition_if_already_started(Item $item, Workflow $workflow, Transition $transition)
 {
     $item->isWorkflowStarted()->willReturn(true);
     $workflow->getTransition(static::TRANSITION_NAME)->willReturn($transition);
     $this->getTransition()->shouldReturn($transition);
 }
Esempio n. 4
0
 function it_throws_than_matches_workflow_is_not_same_as_current(Workflow $workflow, Item $item, EntityId $entityId, Transition $transition, Step $step)
 {
     $step->getName()->willReturn('start');
     $step->isTransitionAllowed('next')->willReturn(true);
     $item->getEntityId()->willReturn($entityId);
     $item->getEntity()->willReturn(static::$entity);
     $item->isWorkflowStarted()->willReturn(true);
     $item->getCurrentStepName()->willReturn('start');
     $item->getWorkflowName()->willReturn('workflow_a');
     $workflow->match($entityId, static::$entity)->willReturn(true);
     $workflow->getStep('start')->willReturn($step);
     $workflow->getTransition('next')->willReturn($transition);
     $workflow->getName()->willReturn('workflow_b');
     $entityId->getProviderName()->willReturn(static::ENTITY_PROVIDER_NAME);
     $entityId->__toString()->willReturn(static::ENTITY_PROVIDER_NAME . '::' . static::ENTITY_ID);
     $this->shouldThrow('Netzmacht\\Workflow\\Flow\\Exception\\WorkflowException')->duringHandle($item, 'next');
 }