public function test()
 {
     $factory = new CurlClientFactory();
     $client = $factory->createClient(['host' => '127.0.0.1', 'port' => 15672, 'user' => 'guest', 'password' => 'guest']);
     $this->assertInstanceOf('Metfan\\RabbitSetup\\Http\\CurlClient', $client);
     $this->assertAttributeEquals('127.0.0.1', 'host', $client);
     $this->assertAttributeEquals(15672, 'port', $client);
     $this->assertAttributeEquals('guest', 'user', $client);
     $this->assertAttributeEquals('guest', 'password', $client);
 }
Exemple #2
0
 /**
  * create a client
  *
  * @param $name
  */
 private function createClient($name)
 {
     if (!array_key_exists($name, $this->connections)) {
         throw new \OutOfRangeException(sprintf('Expected connection %s doesn\'t exists', $name));
     }
     if (null !== $this->user) {
         $this->connections[$name]['user'] = $this->user;
     }
     if (null !== $this->password) {
         $this->connections[$name]['password'] = $this->password;
     }
     $this->pool[$name] = $this->factory->createClient($this->connections[$name]);
 }