/** * @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; }
/** * @expectedException \PBergman\Bundle\BeanstalkBundle\Exception\ConnectionException * @expectedExceptionMessage Unable to connect */ public function testConnection() { $manager = new Manager(); $manager->addConfiguration('default', new Configuration('127.0.0.100', 123456, 2, true)); $this->assertInstanceOf('PBergman\\Bundle\\BeanstalkBundle\\Server\\Configuration', $manager->getConfiguration('default')); $this->assertTrue($manager->getConfiguration('default')->isPersistent()); $this->assertSame(123456, $manager->getConfiguration('default')->getPort()); $this->assertSame(2, $manager->getConfiguration('default')->getTimeout()); $manager->getConfiguration('default')->getConnection(); }
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()); }