1 | <?php |
||
9 | class ConsumerTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | public function testOptions() |
||
12 | { |
||
13 | $configuration = [ |
||
14 | 'connection' => 'connection-name', |
||
15 | 'exchange' => [ |
||
16 | 'name' => 'exchange-name', |
||
17 | ], |
||
18 | 'queue' => [ |
||
19 | 'name' => 'queue-name', |
||
20 | ], |
||
21 | 'callback' => 'callback-name', |
||
22 | 'idle_timeout' => 6, |
||
23 | 'qos' => [ |
||
24 | |||
25 | ], |
||
26 | 'auto_setup_fabric_enabled' => false, |
||
27 | 'consumer_tag' => 'test-tag', |
||
28 | 'signals_enabled' => true, |
||
29 | ]; |
||
30 | $options = new Consumer(); |
||
31 | $options->setFromArray($configuration); |
||
32 | |||
33 | static::assertEquals($configuration['connection'], $options->getConnection()); |
||
34 | static::assertInstanceOf('RabbitMqModule\\Options\\Exchange', $options->getExchange()); |
||
35 | static::assertInstanceOf('RabbitMqModule\\Options\\Queue', $options->getQueue()); |
||
36 | static::assertEquals($configuration['callback'], $options->getCallback()); |
||
37 | static::assertEquals($configuration['idle_timeout'], $options->getIdleTimeout()); |
||
38 | static::assertInstanceOf('RabbitMqModule\\Options\\Qos', $options->getQos()); |
||
39 | static::assertEquals(6, $options->getIdleTimeout()); |
||
40 | static::assertEquals($configuration['auto_setup_fabric_enabled'], $options->isAutoSetupFabricEnabled()); |
||
41 | static::assertEquals('test-tag', $options->getConsumerTag()); |
||
42 | static::assertEquals($configuration['signals_enabled'], $options->isSignalsEnabled()); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @expectedException \InvalidArgumentException |
||
47 | */ |
||
48 | public function testSetQueueInvalidValue() |
||
49 | { |
||
50 | $options = new Consumer(); |
||
51 | $options->setQueue(''); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @expectedException \InvalidArgumentException |
||
56 | */ |
||
57 | public function testSetExchangeInvalidValue() |
||
58 | { |
||
59 | $options = new Consumer(); |
||
60 | $options->setExchange(''); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @expectedException \InvalidArgumentException |
||
65 | */ |
||
66 | public function testSetWosInvalidValue() |
||
67 | { |
||
68 | $options = new Consumer(); |
||
69 | $options->setQos(''); |
||
70 | } |
||
71 | } |
||
72 |