/**
  * @covers RabbitMQ\Management\Guarantee::ensureBinding
  */
 public function testEnsureBindingAlreadyBound()
 {
     $exchange = new Exchange();
     $exchange->type = 'fanout';
     $exchange->vhost = '/';
     $exchange->name = 'test.exchange';
     $queue = new Queue();
     $queue->name = 'test.queue';
     $queue->vhost = '/';
     $this->client->addExchange($exchange);
     $this->client->addQueue($queue);
     $binding = new Binding();
     $binding->vhost = '/';
     $binding->source = 'test.exchange';
     $binding->destination = 'test.queue';
     $binding->routing_key = 'special.routing.key';
     $this->client->addBinding($binding);
     $this->object->ensureBinding($binding);
     $found = false;
     foreach ($this->client->listBindingsByExchangeAndQueue('/', 'test.exchange', 'test.queue') as $binding) {
         if ('special.routing.key' === $binding->routing_key) {
             $found = true;
             break;
         }
     }
     $this->client->deleteExchange($exchange->vhost, $exchange->name);
     $this->client->deleteQueue($queue->vhost, $queue->name);
     if (!$found) {
         $this->fail('Unable to find back the binding');
     }
 }
 public function testDeleteBinding()
 {
     $this->createBinding();
     $found = false;
     foreach ($this->object->listBindingsByExchangeAndQueue('/', self::EXCHANGE_TEST_NAME, self::QUEUE_TEST_NAME) as $binding) {
         if ($binding->routing_key == 'rounting.key') {
             $found = $binding;
         }
     }
     $this->object->deleteBinding('/', self::EXCHANGE_TEST_NAME, self::QUEUE_TEST_NAME, $found);
     $found = false;
     foreach ($this->object->listBindingsByExchangeAndQueue('/', self::EXCHANGE_TEST_NAME, self::QUEUE_TEST_NAME) as $binding) {
         if ($binding->routing_key == 'rounting.key') {
             $found = true;
         }
     }
     if ($found) {
         $this->fail('unable to find delete the binding');
     }
 }