11<?php
22namespace Packaged \Queue \Tests ;
33
4+ use Packaged \Config \ConfigSectionInterface ;
5+ use Packaged \Config \Provider \ConfigSection ;
46use Packaged \Queue \Provider \Amqp \AmqpQueueProvider ;
57
68class AmqpTest extends \PHPUnit_Framework_TestCase
@@ -24,12 +26,12 @@ function ($message, $deliveryTag) use ($q)
2426
2527 public function testBatchAck ()
2628 {
27- $ q = AmqpQueueProvider::create ('test.batch.ack ' )
29+ $ config = new ConfigSection ('' , ['wait_time ' => 1 , 'qos_count ' => 250 ]);
30+ $ q = $ this ->_getQueue ('test.batch.ack ' , $ config )
2831 ->declareExchange ()
2932 ->declareQueue ()
3033 ->bindQueue ()
3134 ->purge ();
32- $ q ->config ()->addItem ('wait_time ' , 1 );
3335
3436 $ total = 1000 ;
3537
@@ -68,12 +70,12 @@ function (array $messages) use ($q, &$c)
6870
6971 public function testBatchNack ()
7072 {
71- $ q = AmqpQueueProvider::create ('test.batch.nack ' )
73+ $ config = new ConfigSection ('' , ['wait_time ' => 1 ]);
74+ $ q = $ this ->_getQueue ('test.batch.nack ' , $ config )
7275 ->declareExchange ()
7376 ->declareQueue ()
7477 ->bindQueue ()
7578 ->purge ();
76- $ q ->config ()->addItem ('wait_time ' , 1 );
7779
7880 $ total = 1000 ;
7981
@@ -112,12 +114,12 @@ function (array $messages) use ($q, &$c)
112114
113115 public function testRequeue ()
114116 {
115- $ q = AmqpQueueProvider::create ('test.batch.requeue ' )
117+ $ config = new ConfigSection ('' , ['wait_time ' => 1 ]);
118+ $ q = $ this ->_getQueue ('test.batch.requeue ' , $ config )
116119 ->declareExchange ()
117120 ->declareQueue ()
118121 ->bindQueue ()
119122 ->purge ();
120- $ q ->config ()->addItem ('wait_time ' , 1 );
121123
122124 $ total = 250 ;
123125
@@ -157,4 +159,16 @@ function (array $messages) use ($q, &$count)
157159 );
158160 $ this ->assertEquals ($ total , $ count );
159161 }
162+
163+ protected function _getQueue (
164+ $ queueName , ConfigSectionInterface $ config = null
165+ )
166+ {
167+ $ q = AmqpQueueProvider::create ($ queueName );
168+ if ($ config )
169+ {
170+ $ q ->configure ($ config );
171+ }
172+ return $ q ;
173+ }
160174}
0 commit comments