@@ 137-158 (lines=22) @@ | ||
134 | new Exchange($client, '', 'direct'); |
|
135 | } |
|
136 | ||
137 | public function testDefaultExchange() |
|
138 | { |
|
139 | $client = $this->makeClient(); |
|
140 | // Let's send a message on RabbitMQ default exchange (named "") |
|
141 | $exchange = new DefaultExchange($client); |
|
142 | $queue = new Queue($client, 'test_direct_queue', [ |
|
143 | new Consumer(function(AMQPMessage $msg) { |
|
144 | $this->msgReceived = $msg; |
|
145 | }, new NullLogger()) |
|
146 | ]); |
|
147 | ||
148 | // The key is the name of the queue. |
|
149 | $exchange->publish(new Message('hello'), 'test_direct_queue'); |
|
150 | ||
151 | $consumerService = new ConsumerService($client, [ |
|
152 | $queue |
|
153 | ]); |
|
154 | ||
155 | $consumerService->run(true); |
|
156 | ||
157 | $this->assertEquals('hello', $this->msgReceived->getBody()); |
|
158 | } |
|
159 | ||
160 | public function testPublishToQueue() |
|
161 | { |
|
@@ 160-179 (lines=20) @@ | ||
157 | $this->assertEquals('hello', $this->msgReceived->getBody()); |
|
158 | } |
|
159 | ||
160 | public function testPublishToQueue() |
|
161 | { |
|
162 | $client = $this->makeClient(); |
|
163 | $queue = new Queue($client, 'test_direct_queue', [ |
|
164 | new Consumer(function (AMQPMessage $msg) { |
|
165 | $this->msgReceived = $msg; |
|
166 | }, new NullLogger()) |
|
167 | ]); |
|
168 | ||
169 | // The key is the name of the queue. |
|
170 | $queue->publish(new Message('hello')); |
|
171 | ||
172 | $consumerService = new ConsumerService($client, [ |
|
173 | $queue |
|
174 | ]); |
|
175 | ||
176 | $consumerService->run(true); |
|
177 | ||
178 | $this->assertEquals('hello', $this->msgReceived->getBody()); |
|
179 | } |
|
180 | ||
181 | /** |
|
182 | * @expectedException \Mouf\AmqpClient\Exception\ConnectionException |