Example #1
0
 public function test_unShift_and_pop()
 {
     $input = [1, 2, 3];
     $this->queue->unShift($input);
     $output = $this->queue->pop(3);
     $this->assertEquals(array_reverse($input), $output);
 }
 public function test_popped_items_are_consecutive_when_using_blpop()
 {
     $messageQueue = new Queue($this->redis, 'fifo:message_queue');
     for ($i = 0; $i < 2; $i++) {
         if (!$this->fork()) {
             $items = $this->queue->pop(2, 100);
             if (is_array($items) && count($items) == 2 && $items[1] == $items[0] + 1) {
                 $messageQueue->unShift(['OK']);
             } else {
                 $messageQueue->unShift(['ERROR']);
             }
             exit(0);
         }
     }
     sleep($this->childSleep);
     $this->queue->push([1, 2, 3, 4]);
     $this->assertEquals(['OK'], $messageQueue->dequeue(1, 100));
     $this->assertEquals(['OK'], $messageQueue->dequeue(1, 100));
 }
Example #3
0
 public function unShift(array $items)
 {
     $this->mainQueue->unShift($items);
     return $this->safeQueue->unShift(array_fill(0, count($items), 1));
 }