Exemplo n.º 1
0
 /**
  * @expectedException        \PBergman\Bundle\BeanstalkBundle\Exception\ConnectionException
  * @expectedExceptionMessage No connection defined by name: "default"
  */
 public function testRemoveConnection()
 {
     $manager = new Manager();
     $manager->addConfiguration('default', new Configuration('127.0.0.100', 123456, 2, true));
     unset($manager['default']);
     unset($manager['default']);
 }
Exemplo n.º 2
0
 public function testDefault()
 {
     $manager = new Manager();
     for ($i = 0; $i < 10; $i++) {
         $manager[] = new Configuration(sprintf('127.0.0.%d', $i));
     }
     $this->assertSame('127.0.0.0', $manager->getConfiguration()->getHost());
 }
Exemplo n.º 3
0
 /**
  * @param   string  $cn     connection name, if none given it will use the first one (default)
  *
  * @return  bool|BeanstalkProducer
  * @throws \PBergman\Bundle\BeanstalkBundle\Exception\ConnectionException
  */
 public function getProducer($cn = null)
 {
     $config = $this->connectionManager->getConfiguration($cn);
     if (false === ($producer = $this->findActiveProducer($config))) {
         $producer = new BeanstalkProducer($config, $this->dispatcher);
         $this->attach($producer, self::ACTIVE_PRODUCERS);
     }
     return $producer;
 }