Пример #1
0
 public function testSetTtl()
 {
     $queue = new CM_Queue('ttl');
     $queue->push('foo');
     $queue->setTtl(0);
     $this->assertSame(false, $queue->pop());
 }
Пример #2
0
 public function testPushPopDelayed()
 {
     $queue = new CM_Queue('foo');
     $timestamp = time();
     $queue->push('bla', $timestamp);
     $this->assertSame(array('bla'), $queue->pop($timestamp));
     $this->assertSame(array(), $queue->pop($timestamp));
     $timeStamp1 = time();
     $timeStamp2 = time() + 10;
     $timeStamp3 = time() + 20;
     $queue->push(1, $timeStamp1);
     $queue->push('two', $timeStamp2);
     $queue->push(array(3 => 'three'), $timeStamp3);
     $this->assertSame(array(1), $queue->pop($timeStamp1));
     $this->assertSame(array(), $queue->pop($timeStamp1));
     $this->assertSame(array('two', array(3 => 'three')), $queue->pop($timeStamp3));
     $this->assertSame(array(), $queue->pop($timeStamp3));
 }