/** * @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']); }
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()); }
/** * @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; }