public function setUp() { $config = array('humus_amqp_module' => array('default_connection' => 'default', 'exchanges' => array('test-rpc-server' => array('name' => 'test-rpc-server', 'type' => 'direct')), 'queues' => array('test-rpc-server' => array('name' => 'test-rpc-server', 'exchange' => 'test-rpc-server')), 'rpc_servers' => array('test-rpc-server' => array('connection' => 'default', 'queue' => 'test-rpc-server', 'callback' => 'test-callback', 'listeners' => ['My\\Listener'], 'logger' => 'custom-log', 'qos' => array('prefetchSize' => 0, 'prefetchCount' => 1))))); $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); $myListener = $this->getMock('Zend\\EventManager\\ListenerAggregateInterface'); $customLog = $this->getMock('Zend\\Log\\LoggerInterface'); $services = $this->services = new ServiceManager(); $services->setAllowOverride(true); $services->setService('Config', $config); $callbackManager = new CallbackPluginManager(); $callbackManager->setInvokableClass('test-callback', __NAMESPACE__ . '\\TestAsset\\TestCallback'); $callbackManager->setServiceLocator($services); $services->setService('HumusAmqpModule\\PluginManager\\Connection', $connectionManager); $services->setService('HumusAmqpModule\\PluginManager\\Callback', $callbackManager); $services->setService('My\\Listener', $myListener); $services->setService('custom-log', $customLog); $components = $this->components = new TestAsset\RpcServerAbstractServiceFactory(); $components->setChannelMock($channel); $components->setQueueFactory($queueFactory); $services->setService('HumusAmqpModule\\PluginManager\\RpcClient', $rpcsm = new RpcServerPluginManager()); $rpcsm->addAbstractFactory($components); $rpcsm->setServiceLocator($services); $services->setService('HumusAmqpModule\\PluginManager\\Callback', $callbackManager = new CallbackPluginManager()); $callbackManager->setInvokableClass('test-callback', __NAMESPACE__ . '\\TestAsset\\TestCallback'); $callbackManager->setServiceLocator($services); }
public function prepare($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); $myListener = $this->getMock('Zend\\EventManager\\ListenerAggregateInterface'); $services = $this->services = new ServiceManager(); $services->setAllowOverride(true); $services->setService('Config', $config); $callbackManager = new CallbackPluginManager(); $callbackManager->setInvokableClass('test-callback', __NAMESPACE__ . '\\TestAsset\\TestCallback'); $callbackManager->setServiceLocator($services); $services->setService('HumusAmqpModule\\PluginManager\\Connection', $connectionManager); $services->setService('HumusAmqpModule\\PluginManager\\Callback', $callbackManager); $services->setService('My\\Listener', $myListener); $components = $this->components = new ConsumerAbstractServiceFactory(); $components->setChannelMock($channel); $components->setQueueFactory($queueFactory); $services->setService('HumusAmqpModule\\PluginManager\\Consumer', $consumerManager = new ConsumerPluginManager()); $consumerManager->addAbstractFactory($components); $consumerManager->setServiceLocator($services); }
/** * @expectedException HumusAmqpModule\Exception\RuntimeException */ public function testInvalidPlugin() { $manager = new CallbackPluginManager(); $manager->validatePlugin('foo'); }