Completed
Push — master ( be1f89...dd7c75 )
by Artem
13:35
created

ExchangeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 3
dl 0
loc 57
rs 10
1
<?php
2
3
namespace RabbitMqModule\Options;
4
5
/**
6
 * Class ExchangeTest
7
 * @package RabbitMqModule\Options
8
 */
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