コード例 #1
0
 /**
  * @test
  */
 public function publishMessageWithDelayAndWaitAndReserveUsingTimeoutAndFinishMessage()
 {
     // Make sure the queue is empty.
     $this->assertSame(null, $this->queue->waitAndReserve(), 'Queue should be empty!');
     // Publish new message.
     $newMessage = new Message('TYPO3');
     $newMessage->setAvailableAt(new \DateTime('now + 2sec'));
     $this->assertSame(2, $newMessage->getDelay(), 'Delay does not  match!');
     $this->queue->publish($newMessage);
     // Do the tests.
     $this->assertSame(null, $this->queue->waitAndReserve(), 'There should be no job available at this moment!');
     $message = $this->queue->waitAndReserve(3);
     $this->assertInstanceOf(Message::class, $message);
     $this->assertSame(Message::STATE_RESERVED, $message->getState(), 'Message has not the state reserved!');
     $this->assertNotEmpty($message->getIdentifier(), 'Message identifier should be set!');
     $this->assertTrue($this->queue->finish($message), 'Message could not be finished!');
     $this->assertSame(Message::STATE_DONE, $message->getState(), 'Message has not the state done!');
 }
コード例 #2
0
 /**
  * @test
  */
 public function setAvailableAtAndGetDelay()
 {
     $dateTimeFixture = new \DateTime('now + 7sec');
     $this->subject->setAvailableAt($dateTimeFixture);
     $this->assertSame(7, $this->subject->getDelay());
 }