1 | <?php |
||
7 | class BindingManagerTest extends AbstractManagerTest |
||
8 | { |
||
9 | private $bindings; |
||
10 | |||
11 | private $bindingManager; |
||
12 | |||
13 | public function setUp() |
||
14 | { |
||
15 | parent::setUp(); |
||
16 | |||
17 | $this->bindings = $this->prophesize('RabbitMq\ManagementApi\Api\Binding'); |
||
18 | $this->client->bindings()->willReturn($this->bindings->reveal()); |
||
19 | |||
20 | $this->bindingManager = new BindingManager(); |
||
21 | } |
||
22 | |||
23 | public function test_define_create() |
||
24 | { |
||
25 | $bindings = array( |
||
26 | array('exchange' => 'bar', 'routing_key' => 'foo.#') |
||
27 | ); |
||
28 | |||
29 | $exception = $this->get404Exception(); |
||
30 | $this->bindings->get('vhost', 'bar', 'foo', 'foo.#')->willThrow($exception->reveal()); |
||
31 | |||
32 | $this->bindings->create('vhost', 'bar', 'foo', 'foo.#')->shouldBeCalled(); |
||
33 | |||
34 | $this->bindingManager->define($this->configuration->reveal(), 'foo', $bindings); |
||
35 | } |
||
36 | |||
37 | public function test_define_bindingExists() |
||
38 | { |
||
39 | $bindings = array( |
||
40 | array('exchange' => 'bar', 'routing_key' => 'foo.#') |
||
41 | ); |
||
42 | |||
43 | $this->bindings->get('vhost', 'bar', 'foo', 'foo.#')->willReturn(array()); |
||
44 | |||
45 | $this->bindings->create('vhost', 'bar', 'foo', 'foo.#')->shouldNotBeCalled(); |
||
46 | |||
47 | $this->bindingManager->define($this->configuration->reveal(), 'foo', $bindings); |
||
48 | } |
||
49 | } |
||
50 |