/**
  * Тестирование получения уже пройденных шагов
  *
  * Также проверяетя сортировка
  */
 public function testFindHistorySteps()
 {
     $em = $this->doctrineWorkflowStory->getEntityManager();
     /** @var StepRepository  $currentStepRep */
     $currentStepRep = $em->getRepository(Step::class);
     $entry = $this->doctrineWorkflowStory->createEntry('test_workflow_name');
     //create step 1
     $stepId = 7;
     $owner = 'test_user_login1';
     $startDate = new DateTime();
     $dueDate = new DateTime();
     $status = 'finish';
     $id = $this->doctrineWorkflowStory->createCurrentStep($entry->getId(), $stepId, $owner, $startDate, $dueDate, $status);
     /** @var Step $step1 */
     $step1 = $currentStepRep->find($id);
     $finishDateStep1 = new DateTime('2005-01-01');
     $this->doctrineWorkflowStory->markFinished($step1, 7, $finishDateStep1, 'test', 'test');
     $this->doctrineWorkflowStory->moveToHistory($step1);
     //create step 2
     $stepId = 8;
     $owner = 'test_user_login1';
     $startDate = new DateTime();
     $dueDate = new DateTime();
     $status = 'finish';
     $id = $this->doctrineWorkflowStory->createCurrentStep($entry->getId(), $stepId, $owner, $startDate, $dueDate, $status);
     /** @var Step $step2 */
     $step2 = $currentStepRep->find($id);
     $finishDateStep2 = new DateTime('2003-01-01');
     $this->doctrineWorkflowStory->markFinished($step2, 7, $finishDateStep2, 'test', 'test');
     $this->doctrineWorkflowStory->moveToHistory($step2);
     //create step 3
     $stepId = 9;
     $owner = 'test_user_login1';
     $startDate = new DateTime();
     $dueDate = new DateTime();
     $status = 'finish';
     $id = $this->doctrineWorkflowStory->createCurrentStep($entry->getId(), $stepId, $owner, $startDate, $dueDate, $status);
     /** @var Step $step3 */
     $step3 = $currentStepRep->find($id);
     $finishDateStep3 = new DateTime('2004-01-01');
     $this->doctrineWorkflowStory->markFinished($step3, 7, $finishDateStep3, 'test', 'test');
     $this->doctrineWorkflowStory->moveToHistory($step3);
     //create step 4
     $stepId = 10;
     $owner = 'test_user_login1';
     $startDate = new DateTime();
     $dueDate = new DateTime();
     $status = 'finish';
     $this->doctrineWorkflowStory->createCurrentStep($entry->getId(), $stepId, $owner, $startDate, $dueDate, $status);
     $em->clear();
     /** @var StepInterface[]|\Iterator $historySteps */
     $historySteps = $this->doctrineWorkflowStory->findHistorySteps($entry->getId());
     static::assertCount(3, $historySteps);
     $historySteps->rewind();
     static::assertEquals($step2->getStepId(), $historySteps->current()->getStepId());
     $historySteps->next();
     static::assertEquals($step3->getStepId(), $historySteps->current()->getStepId());
     $historySteps->next();
     static::assertEquals($step1->getStepId(), $historySteps->current()->getStepId());
 }
 /**
  * Проверка создания фабрики отвечающей за порождение менеджера сущностей доктрины
  *
  * @expectedException \OldTown\Workflow\Spi\Doctrine\Exception\DoctrineRuntimeException
  * @expectedExceptionMessage EntityManager not implement Doctrine\ORM\EntityManagerInterface
  */
 public function testGetEntityManagerInvalidResult()
 {
     $factoryMock = $this->getMockClass(EntityManagerFactoryInterface::class, ['factory']);
     $doctrineWorkflowStory = new DoctrineWorkflowStory();
     $doctrineWorkflowStory->init([DoctrineWorkflowStory::ENTITY_MANAGER_FACTORY => [DoctrineWorkflowStory::ENTITY_MANAGER_FACTORY_NAME => $factoryMock]]);
     /** @var EntityManagerFactoryInterface|PHPUnit_Framework_MockObject_MockObject $factoryMock */
     $factoryMock = $doctrineWorkflowStory->getEntityManagerFactory();
     $factoryMock->expects(static::once())->method('factory')->will(static::returnValue('invalid values'));
     $doctrineWorkflowStory->getEntityManager();
 }