function it_does_not_match_if_step_has_no_assigned_role(Transition $transition, Item $item, Context $context, Step $step, ErrorCollection $errorCollection) { $item->isWorkflowStarted()->willReturn(true); $item->getCurrentStepName()->willReturn('step'); $step->getPermission()->willReturn(null); $errorCollection->addError(Argument::cetera())->shouldBeCalled(); $this->match($transition, $item, $context, $errorCollection)->shouldReturn(false); }
/** * Create the steps. * * @param Workflow $workflow The current workflow. * * @return void */ private function createSteps(Workflow $workflow) { $collection = StepModel::findByWorkflow($workflow->getConfigValue('id')); if (!$collection) { return; } while ($collection->next()) { /** @var StepModel $model */ $model = $collection->current(); $step = new Step($model->name, $model->label, array_merge($collection->row(), array(Definition::SOURCE => Definition::SOURCE_DATABASE))); $step->setFinal($model->final); if ($model->limitPermission) { $step->setPermission(Permission::fromString($model->permission)); } $workflow->addStep($step); $event = new CreateStepEvent($workflow, $step); $this->getServiceContainer()->getEventDispatcher()->dispatch($event::NAME, $event); $this->steps[$model->id] = $step; } }
function it_knows_if_transition_is_available_for_an_item(Item $item, Step $step, Context $context, Transition $transition, ErrorCollection $errorCollection) { $item->isWorkflowStarted()->willReturn(true); $item->getCurrentStepName()->willReturn('started'); $transition->getName()->willReturn('next'); $transition->isAvailable($item, $context, $errorCollection)->shouldBeCalled()->willReturn(true); $this->addTransition($transition); $step->getName()->willReturn('started'); $step->isTransitionAllowed('next')->willReturn(true); $this->addStep($step); $this->isTransitionAvailable($item, $context, $errorCollection, 'next')->shouldReturn(true); }
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'); }