public function testEvict()
 {
     // test1
     $data = "data1";
     $q = new PriorityHashQueue();
     $q->push("test_evict_key", $data, 1);
     $result = $q->evict(2);
     $this->assertInstanceOf('Awdn\\VigilantQueue\\Queue\\QueueItem', $result);
     $this->assertEquals('5:' . $data, $result->getData());
     $result = $q->evict(2);
     $this->assertNull($result);
     // test two objects
     $data = "data1";
     $data2 = "data2";
     $q = new PriorityHashQueue();
     $q->push("test_evict_key", $data, 1);
     $q->push("test_evict_key2", $data2, 3);
     $this->assertEquals(2, $q->count());
     $result = $q->evict(2);
     $this->assertInstanceOf('Awdn\\VigilantQueue\\Queue\\QueueItem', $result);
     $this->assertEquals("5:" . $data, $result->getData());
     $result = $q->evict(2);
     $this->assertNull($result);
     $result = $q->evict(3);
     $this->assertInstanceOf("Awdn\\VigilantQueue\\Queue\\QueueItem", $result);
     $this->assertEquals("5:" . $data2, $result->getData());
     $this->assertEquals(0, $q->count());
 }
Esempio n. 2
0
 /**
  * This allows to set a given dataMode for a request message type. Data mode can be one of
  * PriorityHashQueue::DATA_MODE_REPLACE or PriorityHashQueue::DATA_MODE_APPEND.
  *
  * Later this should become configurable via API.
  *
  * @param string $type
  * @param string $dataMode
  */
 public function setDataModeByType($type, $dataMode)
 {
     $this->queue->setDataModeByType($type, $dataMode);
 }