|
1 | 1 | <?php
|
2 |
| - |
3 | 2 | namespace Codeception\Module;
|
4 | 3 |
|
| 4 | +use Codeception\Module as CodeceptionModule; |
5 | 5 | use Codeception\Exception\ModuleException as ModuleException;
|
| 6 | +use Codeception\TestCase; |
6 | 7 | use Exception;
|
7 | 8 | use PhpAmqpLib\Channel\AMQPChannel;
|
8 | 9 | use PhpAmqpLib\Connection\AMQPConnection;
|
9 | 10 | use PhpAmqpLib\Message\AMQPMessage;
|
| 11 | +use PhpAmqpLib\Exception\AMQPProtocolChannelException; |
10 | 12 |
|
11 | 13 | /**
|
12 | 14 | * This module interacts with message broker software that implements
|
|
54 | 56 |
|
55 | 57 | * @author davert
|
56 | 58 | */
|
57 |
| -class AMQP extends \Codeception\Module |
| 59 | +class AMQP extends CodeceptionModule |
58 | 60 | {
|
59 | 61 | protected $config = [
|
60 | 62 | 'host' => 'locahost',
|
@@ -87,12 +89,12 @@ public function _initialize()
|
87 | 89 |
|
88 | 90 | try {
|
89 | 91 | $this->connection = new AMQPConnection($host, $port, $username, $password, $vhost);
|
90 |
| - } catch (\Exception $e) { |
| 92 | + } catch (Exception $e) { |
91 | 93 | throw new ModuleException(__CLASS__, $e->getMessage() . ' while establishing connection to MQ server');
|
92 | 94 | }
|
93 | 95 | }
|
94 | 96 |
|
95 |
| - public function _before(\Codeception\TestCase $test) |
| 97 | + public function _before(TestCase $test) |
96 | 98 | {
|
97 | 99 | if ($this->config['cleanup']) {
|
98 | 100 | $this->cleanup();
|
@@ -200,8 +202,8 @@ protected function cleanup()
|
200 | 202 | foreach ($this->config['queues'] as $queue) {
|
201 | 203 | try {
|
202 | 204 | $this->connection->channel()->queue_purge($queue);
|
203 |
| - } catch (\PhpAmqpLib\Exception\AMQPProtocolChannelException $e) { |
204 |
| - # ignore if exchange/queue doesn't exist and rethrow exception if it's something else |
| 205 | + } catch (AMQPProtocolChannelException $e) { |
| 206 | + // ignore if exchange/queue doesn't exist and rethrow exception if it's something else |
205 | 207 | if ($e->getCode() !== 404) {
|
206 | 208 | throw $e;
|
207 | 209 | }
|
|
0 commit comments