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