You are here

public function Redis_Tests_Queue_QueueUnitTestCase::testOrder in Redis 7.3

File

lib/Redis/Tests/Queue/QueueUnitTestCase.php, line 79

Class

Redis_Tests_Queue_QueueUnitTestCase
Some tests in there credits goes to the redis_queue module. Thanks to their author.

Code

public function testOrder() {
  $keys = array(
    'test1',
    'test2',
    'test3',
  );
  foreach ($keys as $k) {
    $this->queue
      ->createItem($k);
  }
  $first = $this->queue
    ->claimItem();
  $this
    ->assertEqual($first->data, $keys[0]);
  $second = $this->queue
    ->claimItem();
  $this
    ->assertEqual($second->data, $keys[1]);
  $this->queue
    ->releaseItem($first);
  $third = $this->queue
    ->claimItem();
  $this
    ->assertEqual($third->data, $keys[2]);
  $first_again = $this->queue
    ->claimItem();
  $this
    ->assertEqual($first_again->data, $keys[0]);
  $num = $this->queue
    ->numberOfItems();
  $this
    ->assertEqual(0, $num);
}