public function testGetTransitionDateAndPrePersist()
 {
     $this->assertNull($this->transitionRecord->getTransitionDate());
     $this->transitionRecord->prePersist();
     $this->assertInstanceOf('\\DateTime', $this->transitionRecord->getTransitionDate());
     $this->assertEquals(time(), $this->transitionRecord->getTransitionDate()->getTimestamp(), '', 5);
 }
Beispiel #2
0
 /**
  * @param WorkflowItem $workflowItem
  * @param Transition $transition
  * @return WorkflowTransitionRecord
  * @throws WorkflowException
  */
 protected function createTransitionRecord(WorkflowItem $workflowItem, Transition $transition)
 {
     $transitionName = $transition->getName();
     $stepFrom = $workflowItem->getCurrentStep();
     $stepName = $transition->getStepTo()->getName();
     $stepTo = $this->getDefinition()->getStepByName($stepName);
     if (!$stepTo) {
         throw new WorkflowException(sprintf('Workflow "%s" does not have step entity "%s"', $this->getName(), $stepName));
     }
     $transitionRecord = new WorkflowTransitionRecord();
     $transitionRecord->setTransitionName($transitionName)->setStepFrom($stepFrom)->setStepTo($stepTo);
     return $transitionRecord;
 }
Beispiel #3
0
 /**
  * @param WorkflowTransitionRecord $transitionRecord
  * @return WorkflowItem
  */
 public function addTransitionRecord(WorkflowTransitionRecord $transitionRecord)
 {
     $transitionRecord->setWorkflowItem($this);
     $this->transitionRecords->add($transitionRecord);
     return $this;
 }
 public function testGetAddTransitionRecords()
 {
     $this->assertEmpty($this->workflowItem->getTransitionRecords()->getValues());
     $transitionRecord = new WorkflowTransitionRecord();
     $transitionRecord->setTransitionName('test_transition');
     $this->assertEquals($this->workflowItem, $this->workflowItem->addTransitionRecord($transitionRecord));
     $this->assertEquals(array($transitionRecord), $this->workflowItem->getTransitionRecords()->getValues());
     $this->assertEquals($this->workflowItem, $transitionRecord->getWorkflowItem());
 }
 /**
  * @param WorkflowItem $workflowItem
  * @param Transition $transition
  * @return WorkflowTransitionRecord
  */
 protected function createTransitionRecord(WorkflowItem $workflowItem, Transition $transition)
 {
     $transitionName = $transition->getName();
     $stepFrom = $workflowItem->getCurrentStepName();
     $stepTo = $transition->getStepTo()->getName();
     $transitionRecord = new WorkflowTransitionRecord();
     $transitionRecord->setTransitionName($transitionName)->setStepFromName($stepFrom)->setStepToName($stepTo);
     return $transitionRecord;
 }