/**
  * @dataProvider providerGetAll
  * @param $vhost
  * @param $expectedUrl
  */
 public function testGetAll($vhost, $expectedUrl)
 {
     $manager = new QueueManager();
     $manager->setClient($this->client);
     $this->client->expects($this->once())->method('query')->with(ClientInterface::METHOD_GET, $expectedUrl)->willReturn(json_encode(['queues' => 'test']));
     $this->assertEquals(['queues' => 'test'], $manager->getAll($vhost));
 }
Beispiel #2
0
 /**
  * Delete selected queues.
  * If queues == "*" get list of queue from rabbitmq API
  *
  * @param $vhost
  * @param $queues
  */
 public function deleteQueues($vhost, $queues)
 {
     if ('*' === $queues) {
         //so you want to destroy all queues, as you whish, let me time to list' em all
         $queues = $this->queueManager->getAll(urlencode($vhost));
     } elseif (!$vhost) {
         throw new \InvalidArgumentException('If you want to delete certain queue(s) you have to provide vhost');
     } else {
         //few queues to delete, let stack them in array
         $queues = explode(',', $queues);
         array_walk($queues, function (&$item, $key, $vhost) {
             $item = ['vhost' => $vhost, 'name' => trim($item)];
         }, $vhost);
     }
     if (0 == count($queues)) {
         $this->logger->error('No queue found.');
         return;
     }
     foreach ($queues as $queue) {
         $this->queueManager->delete(urlencode($queue['vhost']), $queue['name']);
     }
 }