protected function getProcessHandler()
 {
     $stepValidateDoc = new Step('step_validate_doc', 'Validate doc', array(), array(), array('setStatus', 'FreeAgent\\WorkflowBundle\\Tests\\Fixtures\\FakeModel::STATUS_VALIDATE'));
     $stepRemoveDoc = new Step('step_remove_doc', 'Remove doc', array(), array(array(new FakeValidator(), 'invalid')), array('setStatus', 'FreeAgent\\WorkflowBundle\\Tests\\Fixtures\\FakeModel::STATUS_REMOVE'), array(), 'step_fake');
     $stepFake = new Step('step_fake', 'Fake', array());
     $stepCreateDoc = new Step('step_create_doc', 'Create doc', array(), array(), array('setStatus', 'FreeAgent\\WorkflowBundle\\Tests\\Fixtures\\FakeModel::STATUS_CREATE'));
     $stepCreateDoc->addNextState('validate', NextStateInterface::TARGET_TYPE_STEP, $stepValidateDoc);
     $stepCreateDoc->addNextState('remove', NextStateInterface::TARGET_TYPE_STEP, $stepRemoveDoc);
     $process = new Process('document_proccess', array('step_create_doc' => $stepCreateDoc, 'step_validate_doc' => $stepValidateDoc, 'step_remove_doc' => $stepRemoveDoc, 'step_fake' => $stepFake), 'step_create_doc', array('step_validate_doc'));
     $dispatcher = new EventDispatcher();
     $dispatcher->addListener('document_proccess.step_fake.reached', array(new FakeProcessListener(), 'handleSucccess'));
     $processHandler = new ProcessHandler($process, $this->modelStorage, $dispatcher);
     $processHandler->setSecurityContext(new FakeSecurityContext());
     return $processHandler;
 }
 /**
  * Check if the user is allowed to reach the step.
  *
  * @param Step $step
  * @throws AccessDeniedException
  */
 protected function checkCredentials(Step $step)
 {
     $roles = $step->getRoles();
     if (!empty($roles) && !$this->security->isGranted($roles)) {
         throw new AccessDeniedException($step->getName());
     }
 }