예제 #1
0
 /**
  * @covers ::getAdapterFactoryConfig
  * @covers ::<private>
  */
 public function testTestingAdapterFactoryCanBeRetrieved()
 {
     $message_bank_factory = new MessageBankFactory();
     $adapter_factory_config = ['type' => 'testing', 'message_bank_factory' => $message_bank_factory];
     $message_queue_config = new MessageQueueConfig(new QueueConfig([]), $adapter_factory_config);
     $message_bank_factory->setConfig($message_queue_config);
     $this->assertEquals($adapter_factory_config, $message_queue_config->getAdapterFactoryConfig());
 }
예제 #2
0
 /**
  * @covers ::__construct
  * @covers ::getQueue
  * @covers ::consume
  * @covers ::<private>
  */
 public function testTimePerConsumeIsRespected()
 {
     $message_bank = $this->message_bank_factory->getMessageBank('limited-time-queue');
     for ($i = 1; $i <= 3; $i++) {
         $message_bank->produceMessage(json_encode($i));
     }
     $sum = 0;
     $this->consumer->getQueue('limited-time-queue')->consume(function (IncomingMessage $message) use(&$sum) {
         sleep(2);
         $sum += $message->getContent();
     });
     $this->assertSame(1, $sum);
 }
예제 #3
0
 /**
  * @param string $queue_name
  * @return MessageBank
  */
 public function getMessageBank($queue_name)
 {
     return $this->message_bank_factory->getMessageBank($queue_name);
 }
예제 #4
0
파일: Factory.php 프로젝트: lightster/hodor
 /**
  * @param string $queue_key
  * @return MessageBank
  */
 private function getMessageBank($queue_key)
 {
     return $this->message_bank_factory->getMessageBank($queue_key);
 }
예제 #5
0
 /**
  * @covers ::getConfig
  * @expectedException Exception
  */
 public function testConfigCannotBeRetrievedIfItIsNotSet()
 {
     $message_bank_factory = new MessageBankFactory();
     $message_bank_factory->getConfig();
 }