Ejemplo n.º 1
0
 public function testResolveTimeoutsWithPayloadInCorrectState()
 {
     $timeout = $this->getMockBuilder('\\StateMachine\\PayloadTimeout')->disableOriginalConstructor()->getMock();
     $timeout->expects($this->any())->method('getState')->willReturn('timeout');
     $this->timeoutHandler->expects($this->any())->method('getExpired')->willReturn([$timeout]);
     $this->payload->expects($this->any())->method('getState')->willReturn('timeout');
     $this->payloadHandler->expects($this->any())->method('restore')->willReturn($this->payload);
     $this->adapter->expects($this->any())->method('getProcess')->willReturn($this->process);
     $this->process->expects($this->once())->method('triggerEvent');
     $this->timeoutHandler->expects($this->once())->method('remove');
     $machine = new StateMachine($this->adapter, $this->payloadHandler, $this->timeoutHandler, $this->lockHandler);
     $machine->resolveTimeouts();
 }
Ejemplo n.º 2
0
 public function testGetTimeout()
 {
     $date = new \DateTime();
     $event = $this->getMockBuilder('\\StateMachine\\EventInterface')->disableOriginalConstructor()->getMock();
     $event->expects($this->any())->method('getName')->willReturn(Process::ON_TIME_OUT);
     $event->expects($this->any())->method('timeoutAt')->willReturn($date);
     $this->state->expects($this->any())->method('__toString')->willReturn('stateName');
     $this->state->expects($this->any())->method('getName')->willReturn('stateName');
     $this->state->expects($this->any())->method('getEvent')->willReturn($event);
     $this->payload->expects($this->any())->method('getState')->willReturn('stateName');
     $this->payload->expects($this->any())->method('getIdentifier')->willReturn('identifier');
     $process = new Process('processName', '\\stdClass', 'stateName', [$this->state]);
     $timeout = $process->getTimeout($this->payload, $date);
     $this->assertInstanceOf('\\StateMachine\\PayloadTimeout', $timeout);
     $this->assertEquals('stateName', $timeout->getState());
     $this->assertEquals(Process::ON_TIME_OUT, $timeout->getEvent());
     $this->assertEquals('identifier', $timeout->getIdentifier());
     $this->assertEquals($date, $timeout->getExecutionDate());
 }
Ejemplo n.º 3
0
 /**
  * Get an instance of type \Colada\Europeana\Payload\PayloadHandlerInterface
  *
  * This factory method will create a handler object based on the type of the
  * PayloadInterface objec which is passed as a method argument.
  *
  * @param \Colada\Europeana\Payload\PayloadInterface $payload
  */
 public static function getHandler(PayloadInterface $payload)
 {
     $handler = $payload->getHandlerClass();
     return $handler::create($payload);
 }