public function testGetSetStateDate()
 {
     $instance = new WorkflowInstanceEntity();
     $this->assertNull($instance->getStateDate());
     $date = new \DateTime();
     $date->modify('-1 month');
     $instance->setStateDate($date);
     $this->assertEquals($date, $instance->getStateDate());
 }
Esempio n. 2
0
 /**
  * Move into this state
  *
  * @param  ContextInterface       $context        Workflow context
  * @param  WorkflowInstanceEntity $instanceEntity Instance entity
  *
  * @return WorkflowInstanceEntity Updated instance entity
  */
 public function moveTo(ContextInterface $context, WorkflowInstanceEntity $instanceEntity)
 {
     // Update the instance entity
     $instanceEntity->setStateName($this->getName());
     $instanceEntity->setStateDate(new \DateTime());
     // Call the actions
     $this->callActions($context);
     // Handle the conditions
     $next = $this->evaluateConditions($context);
     if ($next !== null) {
         return $next->moveTo($context, $instanceEntity);
     }
     // Check if this is a terminal state
     if ($this->isTerminal()) {
         $instanceEntity->setIsComplete(true);
     }
     // Return the updated instance entity
     return $instanceEntity;
 }