Пример #1
0
 public function testSetClassFilterInvalidArgument()
 {
     $this->setExpectedException(InvalidArgumentException::class);
     $this->receiveParameter->setClassFilter([]);
 }
Пример #2
0
 public function testClassFilter()
 {
     $queue = $this->createQueue(__FUNCTION__);
     $adapter = $queue->getAdapter();
     $this->checkAdapterSupport('deleteQueue');
     if (!$queue->isReceiveParamSupported(ReceiveParameters::CLASS_FILTER)) {
         $adapter->deleteQueue($queue->getName());
         $this->markTestSkipped($this->getAdapterName() . ' does not support class filter');
         return;
     }
     $body = 'hello world';
     //Test filter matches
     $queue->send($body);
     $reciveParams = new ReceiveParameters();
     $reciveParams->setClassFilter($queue->getOptions()->getMessageClass());
     $messages = $queue->receive(1, $reciveParams);
     $this->assertInstanceOf('\\Stakhanovist\\Queue\\Message\\MessageIterator', $messages);
     $this->assertEquals(1, $messages->count());
     $this->assertInstanceOf($reciveParams->getClassFilter(), $messages->current());
     //Reset the queue
     $adapter->deleteQueue($queue->getName());
     $queue = $this->createQueue(__FUNCTION__);
     $adapter = $queue->getAdapter();
     //Test filter doesnt' match
     $queue->send($body);
     $reciveParams = new ReceiveParameters();
     $reciveParams->setClassFilter('Zend\\Stdlib\\Message');
     //Another class
     $messages = $queue->receive(1, $reciveParams);
     $this->assertInstanceOf('\\Stakhanovist\\Queue\\Message\\MessageIterator', $messages);
     $this->assertEquals(0, $messages->count());
     // delete the queue we created
     $adapter->deleteQueue($queue->getName());
 }