/** * @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()); }
/** * @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); }
/** * @param string $queue_name * @return MessageBank */ public function getMessageBank($queue_name) { return $this->message_bank_factory->getMessageBank($queue_name); }
/** * @param string $queue_key * @return MessageBank */ private function getMessageBank($queue_key) { return $this->message_bank_factory->getMessageBank($queue_key); }
/** * @covers ::getConfig * @expectedException Exception */ public function testConfigCannotBeRetrievedIfItIsNotSet() { $message_bank_factory = new MessageBankFactory(); $message_bank_factory->getConfig(); }