1 | <?php |
||
9 | class ExchangeTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | public function testOptions() |
||
12 | { |
||
13 | $configuration = [ |
||
14 | 'name' => 'test-name', |
||
15 | 'type' => 'type-name', |
||
16 | 'passive' => true, |
||
17 | 'durable' => true, |
||
18 | 'auto_delete' => false, |
||
19 | 'internal' => true, |
||
20 | 'no_wait' => true, |
||
21 | 'ticket' => 1, |
||
22 | 'declare' => true, |
||
23 | 'arguments' => [ |
||
24 | 'argument1' => 'value1', |
||
25 | ], |
||
26 | 'exchange_binds' => [ |
||
27 | [ |
||
28 | 'exchange' => ['name' => 'foo'], |
||
29 | 'routing_keys' => ['routing.1', 'routing.2'], |
||
30 | ], |
||
31 | ], |
||
32 | ]; |
||
33 | $options = new Exchange(); |
||
34 | $options->setFromArray($configuration); |
||
35 | |||
36 | static::assertEquals($configuration['name'], $options->getName()); |
||
37 | static::assertEquals($configuration['type'], $options->getType()); |
||
38 | static::assertEquals($configuration['passive'], $options->isPassive()); |
||
39 | static::assertEquals($configuration['durable'], $options->isDurable()); |
||
40 | static::assertEquals($configuration['auto_delete'], $options->isAutoDelete()); |
||
41 | static::assertEquals($configuration['internal'], $options->isInternal()); |
||
42 | static::assertEquals($configuration['no_wait'], $options->isNoWait()); |
||
43 | static::assertEquals($configuration['ticket'], $options->getTicket()); |
||
44 | static::assertEquals($configuration['declare'], $options->isDeclare()); |
||
45 | static::assertEquals($configuration['arguments'], $options->getArguments()); |
||
46 | |||
47 | $binds = $options->getExchangeBinds(); |
||
48 | static::assertCount(1, $binds); |
||
49 | |||
50 | foreach ($binds as $bind) { |
||
51 | static::assertInstanceOf('RabbitMqModule\\Options\\Exchange', $bind->getExchange()); |
||
52 | static::assertCount(2, $bind->getRoutingKeys()); |
||
53 | static::assertEquals(['routing.1', 'routing.2'], $bind->getRoutingKeys()); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @expectedException \InvalidArgumentException |
||
59 | */ |
||
60 | public function testSetExchangeBindInvalidValue() |
||
61 | { |
||
62 | $options = new Exchange(); |
||
63 | $options->addExchangeBind(''); |
||
64 | } |
||
65 | } |
||
66 |