/** * Tests connection factory exception handling. * * @expectedException \ONGR\TaskMessengerBundle\Publishers\Exception\PublisherConnectionException */ public function testConnectionFactoryException() { $exception = $this->getMockBuilder('\\Exception')->disableOriginalConstructor()->getMock(); $connectionFactory = $this->getMockBuilder('ONGR\\TaskMessengerBundle\\Publishers\\ConnectionFactory')->disableOriginalConstructor()->getMock(); $connectionFactory->expects($this->once())->method('create')->willThrowException($exception); $environment = 'dummy-environment'; $publisher = new BeanstalkdPublisher($connectionFactory, $environment); $task = new SyncTask(SyncTask::SYNC_TASK_BROADCAST); $task->setName('ongr:sync:download'); $expectedEnvironment = 'test'; $task->setEnvironment($expectedEnvironment); $publisher->publish($task); }