Exemple #1
0
 public function __construct(Queue\Client $queue, $data)
 {
     $store = $queue->getStore()->getMessagesStore();
     $this->promisesStore = $queue->getStore()->getPromisesStore();
     $promise = new PromiseClient($this->promisesStore);
     $data = is_null($data) ? [Store::QUEUE_ID => $queue->getId(), Store::PROMISE => $promise->getId()] : is_array($data) ? array_merge($data, [Store::QUEUE_ID => $queue->getId(), Store::PROMISE => $promise->getId()]) : $data;
     parent::__construct($store, $data);
     $this->queue = $queue;
 }
Exemple #2
0
 public function test_MessageTest__make()
 {
     $this->object = new Client($this->queueClient, [Store::MESSAGE_BODY => 'body']);
     $this->assertInstanceOf('zaboy\\async\\Message\\Client', $this->object);
     $this->assertTrue($this->object->isId($this->object->getId()));
     $this->assertEquals('body', $this->object->getBody());
     $this->assertEquals(1, $this->object->getStore()->count([Store::QUEUE_ID => $this->queueClient->getId()]));
     $this->object->remove();
     $this->assertEquals(0, $this->queueClient->getNumberMessages());
 }
Exemple #3
0
 public function test_QueueTest__pullMessagePullPriority()
 {
     $this->object = new Client($this->store);
     $message1 = $this->object->addMessage('3', Message::HIGH);
     $message2 = $this->object->addMessage('1', Message::NORM);
     $message2 = $this->object->addMessage('2', Message::LOW);
     $body = $this->object->pullMessage(Message::NORM);
     $this->assertEquals(1, $body);
     $body = $this->object->pullMessage(Message::LOW);
     $this->assertEquals(2, $body);
     $this->assertNull($this->object->pullMessage(Message::LOW));
     $body = $this->object->pullMessage(Message::HIGH);
     $this->assertEquals(3, $body);
 }