public function setUp()
 {
     $config = array('humus_amqp_module' => array('default_connection' => 'default', 'connections' => array('default' => array('host' => 'localhost', 'port' => 5672, 'login' => 'guest', 'password' => 'guest', 'vhost' => '/')), 'exchanges' => array('demo-exchange' => array('name' => 'demo-exchange', 'type' => 'direct', 'durable' => false, 'autoDelete' => true), 'invalid-exchange' => array('connection' => 'invalid-second')), 'queues' => array('test-queue' => array('name' => 'test-queue', 'exchange' => 'demo-exchange', 'autoDelete' => true)), 'producers' => array('test-producer' => array('connection' => 'default', 'exchange' => 'demo-exchange', 'auto_setup_fabric' => true), 'test-producer-2' => array('exchange' => 'demo-exchange', 'auto_setup_fabric' => true), 'test-producer-3' => array(), 'test-producer-4' => array('exchange' => 'missing-exchange'), 'test-producer-5' => array('connection' => 'invalid-connection', 'exchange' => 'invalid-exchange'))));
     $connection = $this->getMock('AMQPConnection', array(), array(), '', false);
     $channel = $this->getMock('AMQPChannel', array(), array(), '', false);
     $channel->expects($this->any())->method('getPrefetchCount')->will($this->returnValue(10));
     $exchange = $this->getMock('AMQPExchange', array(), array(), '', false);
     $exchangeFactory = $this->getMock('HumusAmqpModule\\ExchangeFactory');
     $exchangeFactory->expects($this->any())->method('create')->will($this->returnValue($exchange));
     $connectionManager = $this->getMock('HumusAmqpModule\\PluginManager\\Connection');
     $connectionManager->expects($this->any())->method('get')->with('default')->willReturn($connection);
     $services = $this->services = new ServiceManager();
     $services->setAllowOverride(true);
     $services->setService('Config', $config);
     $dependentComponent = new ConnectionAbstractServiceFactory();
     $services->setService('HumusAmqpModule\\PluginManager\\Connection', $cm = new ConnectionPluginManager());
     $cm->addAbstractFactory($dependentComponent);
     $cm->setServiceLocator($services);
     $components = $this->components = new TestAsset\ProducerAbstractServiceFactory();
     $components->setChannelMock($channel);
     $components->setExchangeFactory($exchangeFactory);
     $services->setService('HumusAmqpModule\\PluginManager\\Producer', $producerManager = new ProducerPluginManager());
     $producerManager->addAbstractFactory($components);
     $producerManager->setServiceLocator($services);
 }
 protected function prepare($config)
 {
     $services = $this->services = new ServiceManager();
     $services->setAllowOverride(true);
     $services->setService('Config', $config);
     $connection = $this->getMock('AMQPConnection', array(), array(), '', false);
     $channel = $this->getMock('AMQPChannel', array(), array(), '', false);
     $channel->expects($this->any())->method('getPrefetchCount')->will($this->returnValue(10));
     $queue = $this->getMock('AMQPQueue', array(), array(), '', false);
     $queue->expects($this->any())->method('getChannel')->will($this->returnValue($channel));
     $queueFactory = $this->getMock('HumusAmqpModule\\QueueFactory');
     $queueFactory->expects($this->any())->method('create')->will($this->returnValue($queue));
     $connectionManager = $this->getMock('HumusAmqpModule\\PluginManager\\Connection');
     $connectionManager->expects($this->any())->method('get')->with('default')->willReturn($connection);
     $dependentComponent = new ConnectionAbstractServiceFactory();
     $this->services->setService('HumusAmqpModule\\PluginManager\\Connection', $cm = new ConnectionPluginManager());
     $cm->addAbstractFactory($dependentComponent);
     $cm->setServiceLocator($this->services);
     $components = $this->components = new TestAsset\RpcClientAbstractServiceFactory();
     $components->setChannelMock($channel);
     $components->setQueueFactory($queueFactory);
     $this->services->setService('HumusAmqpModule\\PluginManager\\RpcClient', $rpccm = new RpcClientPluginManager());
     $rpccm->addAbstractFactory($components);
     $rpccm->setServiceLocator($this->services);
 }
 public function testMissingGlobalConfigIndicatesCannotCreateInstance()
 {
     $services = $this->services = new ServiceManager();
     $services->setAllowOverride(true);
     $components = $this->components = new ConnectionAbstractServiceFactory();
     $services->setService('HumusAmqpModule\\PluginManager\\Connection', $cm = new ConnectionPluginManager());
     $cm->addAbstractFactory($components);
     $cm->setServiceLocator($services);
     $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
 }
Ejemplo n.º 4
0
 /**
  * @expectedException HumusAmqpModule\Exception\RuntimeException
  */
 public function testInvalidPlugin()
 {
     $manager = new ConnectionPluginManager();
     $manager->validatePlugin('foo');
 }