| @@ 12-52 (lines=41) @@ | ||
| 9 | use Cmobi\RabbitmqBundle\Tests\BaseTestCase; |
|
| 10 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
| 11 | ||
| 12 | class RpcServerPassTest extends BaseTestCase |
|
| 13 | { |
|
| 14 | public function testProcess() |
|
| 15 | { |
|
| 16 | $container = new ContainerBuilder(); |
|
| 17 | $this->declareServiceMock($container); |
|
| 18 | $container->register('cmobi_rabbitmq.message.handler', BaseQueueService::class) |
|
| 19 | ->setPublic(false); |
|
| 20 | $container->register('cmobi_rabbitmq.connection.manager', ConnectionManager::class) |
|
| 21 | ->setPublic(false); |
|
| 22 | ||
| 23 | $this->process($container); |
|
| 24 | ||
| 25 | $this->assertTrue($container->hasDefinition('cmobi_rabbitmq.rpc.test')); |
|
| 26 | } |
|
| 27 | ||
| 28 | private function declareServiceMock(ContainerBuilder $container) |
|
| 29 | { |
|
| 30 | $container->registerExtension(new CmobiRabbitmqExtension()); |
|
| 31 | $container->register('cmobi_rabbitmq.rpc.test') |
|
| 32 | ->setPublic(false); |
|
| 33 | $container->register('cmobi_rabbitmq.connection.default') |
|
| 34 | ->setPublic(false); |
|
| 35 | $container->register('cmobi_rabbitmq.logger') |
|
| 36 | ->setPublic(false); |
|
| 37 | } |
|
| 38 | ||
| 39 | protected function process(ContainerBuilder $container) |
|
| 40 | { |
|
| 41 | $rpcServerPass = new RpcServerPass( |
|
| 42 | 'test', |
|
| 43 | 'cmobi_rabbitmq.connection.default', |
|
| 44 | 'cmobi_rabbitmq.message.handler', |
|
| 45 | 1, |
|
| 46 | false, |
|
| 47 | true, |
|
| 48 | [] |
|
| 49 | ); |
|
| 50 | $rpcServerPass->process($container); |
|
| 51 | } |
|
| 52 | } |
|
| @@ 13-53 (lines=41) @@ | ||
| 10 | use Cmobi\RabbitmqBundle\Transport\Subscriber\ExchangeType; |
|
| 11 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
| 12 | ||
| 13 | class SubscriberPassTest extends BaseTestCase |
|
| 14 | { |
|
| 15 | public function testProcess() |
|
| 16 | { |
|
| 17 | $container = new ContainerBuilder(); |
|
| 18 | $this->declareServiceMock($container); |
|
| 19 | $container->register('cmobi_rabbitmq.message.handler', BaseQueueService::class) |
|
| 20 | ->setPublic(false); |
|
| 21 | $container->register('cmobi_rabbitmq.connection.manager', ConnectionManager::class) |
|
| 22 | ->setPublic(false); |
|
| 23 | ||
| 24 | $this->process($container); |
|
| 25 | ||
| 26 | $this->assertTrue($container->hasDefinition('cmobi_rabbitmq.pub_sub.test')); |
|
| 27 | } |
|
| 28 | ||
| 29 | private function declareServiceMock(ContainerBuilder $container) |
|
| 30 | { |
|
| 31 | $container->registerExtension(new CmobiRabbitmqExtension()); |
|
| 32 | $container->register('cmobi_rabbitmq.pub_sub.test') |
|
| 33 | ->setPublic(false); |
|
| 34 | $container->register('cmobi_rabbitmq.connection.default') |
|
| 35 | ->setPublic(false); |
|
| 36 | $container->register('cmobi_rabbitmq.logger') |
|
| 37 | ->setPublic(false); |
|
| 38 | } |
|
| 39 | ||
| 40 | protected function process(ContainerBuilder $container) |
|
| 41 | { |
|
| 42 | $subscriberPass = new SubscriberPass( |
|
| 43 | 'exchange_test', |
|
| 44 | ExchangeType::FANOUT, |
|
| 45 | 'test', |
|
| 46 | 'cmobi_rabbitmq.connection.default', |
|
| 47 | 'cmobi_rabbitmq.message.handler', |
|
| 48 | 1, |
|
| 49 | [] |
|
| 50 | ); |
|
| 51 | $subscriberPass->process($container); |
|
| 52 | } |
|
| 53 | } |
|
| @@ 12-50 (lines=39) @@ | ||
| 9 | use Cmobi\RabbitmqBundle\Tests\BaseTestCase; |
|
| 10 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
| 11 | ||
| 12 | class WorkerPassTest extends BaseTestCase |
|
| 13 | { |
|
| 14 | public function testProcess() |
|
| 15 | { |
|
| 16 | $container = new ContainerBuilder(); |
|
| 17 | $this->declareServiceMock($container); |
|
| 18 | $container->register('cmobi_rabbitmq.message.handler', BaseQueueService::class) |
|
| 19 | ->setPublic(false); |
|
| 20 | $container->register('cmobi_rabbitmq.connection.manager', ConnectionManager::class) |
|
| 21 | ->setPublic(false); |
|
| 22 | ||
| 23 | $this->process($container); |
|
| 24 | ||
| 25 | $this->assertTrue($container->hasDefinition('cmobi_rabbitmq.worker.test')); |
|
| 26 | } |
|
| 27 | ||
| 28 | private function declareServiceMock(ContainerBuilder $container) |
|
| 29 | { |
|
| 30 | $container->registerExtension(new CmobiRabbitmqExtension()); |
|
| 31 | $container->register('cmobi_rabbitmq.worker.test') |
|
| 32 | ->setPublic(false); |
|
| 33 | $container->register('cmobi_rabbitmq.connection.default') |
|
| 34 | ->setPublic(false); |
|
| 35 | $container->register('cmobi_rabbitmq.logger') |
|
| 36 | ->setPublic(false); |
|
| 37 | } |
|
| 38 | ||
| 39 | protected function process(ContainerBuilder $container) |
|
| 40 | { |
|
| 41 | $workerPass = new WorkerPass( |
|
| 42 | 'test', |
|
| 43 | 'cmobi_rabbitmq.connection.default', |
|
| 44 | 'cmobi_rabbitmq.message.handler', |
|
| 45 | 1, |
|
| 46 | [] |
|
| 47 | ); |
|
| 48 | $workerPass->process($container); |
|
| 49 | } |
|
| 50 | } |
|