1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ola\RabbitMqAdminToolkitBundle\Tests\Manager; |
4
|
|
|
|
5
|
|
|
use Ola\RabbitMqAdminToolkitBundle\Manager\QueueManager; |
6
|
|
|
|
7
|
|
|
class QueueManagerTest extends AbstractManagerTest |
8
|
|
|
{ |
9
|
|
|
private $bindingManager; |
10
|
|
|
private $queues; |
11
|
|
|
private $queueManager; |
12
|
|
|
|
13
|
|
|
public function setUp() |
14
|
|
|
{ |
15
|
|
|
parent::setUp(); |
16
|
|
|
|
17
|
|
|
$this->queues = $this->prophesize('RabbitMq\ManagementApi\Api\Queue'); |
18
|
|
|
$this->client->queues()->willReturn($this->queues->reveal()); |
19
|
|
|
$this->configuration->isDeleteAllowed()->willReturn(false); |
20
|
|
|
$this->bindingManager = $this->prophesize('Ola\RabbitMqAdminToolkitBundle\Manager\BindingManager'); |
21
|
|
|
|
22
|
|
|
$this->queueManager = new QueueManager($this->bindingManager->reveal()); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function test_define_create() |
26
|
|
|
{ |
27
|
|
|
$this->configuration->getConfiguration('queues')->willReturn(array( |
28
|
|
|
'foo' => array('bindings' => array('foo-bind')), |
29
|
|
|
'bar' => array('name' => 'doe', 'bindings' => array('doe-bind')) |
30
|
|
|
)); |
31
|
|
|
|
32
|
|
|
$exception = $this->get404Exception(); |
33
|
|
|
$this->queues->get('vhost', 'foo')->willThrow($exception->reveal()); |
34
|
|
|
$this->queues->get('vhost', 'doe')->willThrow($exception->reveal()); |
35
|
|
|
|
36
|
|
|
$this->queues->create('vhost', 'foo', array())->shouldBeCalled(); |
37
|
|
|
$this->queues->create('vhost', 'doe', array())->shouldBeCalled(); |
38
|
|
|
|
39
|
|
|
$this->bindingManager->define($this->configuration, 'foo', array('foo-bind')); |
40
|
|
|
$this->bindingManager->define($this->configuration, 'doe', array('doe-bind')); |
41
|
|
|
|
42
|
|
|
$this->queueManager->define($this->configuration->reveal()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function test_define_exist() |
46
|
|
|
{ |
47
|
|
|
$this->configuration->getConfiguration('queues')->willReturn(array( |
48
|
|
|
'foo' => array('bindings' => array('foo-bind')), |
49
|
|
|
'bar' => array('name' => 'doe', 'bindings' => array('doe-bind')) |
50
|
|
|
)); |
51
|
|
|
|
52
|
|
|
$this->queues->get('vhost', 'foo')->willReturn(array()); |
53
|
|
|
$this->queues->get('vhost', 'doe')->willReturn(array()); |
54
|
|
|
|
55
|
|
|
$this->queues->create('vhost', 'foo', array())->shouldNotBeCalled(); |
56
|
|
|
$this->queues->create('vhost', 'doe', array())->shouldNotBeCalled(); |
57
|
|
|
|
58
|
|
|
$this->bindingManager->define($this->configuration, 'foo', array('foo-bind')); |
59
|
|
|
$this->bindingManager->define($this->configuration, 'doe', array('doe-bind')); |
60
|
|
|
|
61
|
|
|
$this->queueManager->define($this->configuration->reveal()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function test_define_update() |
65
|
|
|
{ |
66
|
|
|
$this->configuration->getConfiguration('queues')->willReturn(array( |
67
|
|
|
'foo' => array('durable' => true, 'bindings' => array('foo-bind')), |
68
|
|
|
'bar' => array('name' => 'doe', 'durable' => true, 'bindings' => array('doe-bind')) |
69
|
|
|
)); |
70
|
|
|
|
71
|
|
|
$this->configuration->isDeleteAllowed()->willReturn(true); |
72
|
|
|
|
73
|
|
|
$this->queues->get('vhost', 'foo')->willReturn(array('durable' => true)); |
74
|
|
|
$this->queues->get('vhost', 'doe')->willReturn(array('durable' => false)); |
75
|
|
|
|
76
|
|
|
$this->queues->create('vhost', 'foo', array('durable' => true))->shouldNotBeCalled(); |
77
|
|
|
$this->queues->delete('vhost', 'doe')->shouldBeCalled(); |
78
|
|
|
$this->queues->create('vhost', 'doe', array('durable' => true))->shouldBeCalled(); |
79
|
|
|
|
80
|
|
|
$this->bindingManager->define($this->configuration, 'foo', array('foo-bind')); |
81
|
|
|
$this->bindingManager->define($this->configuration, 'doe', array('doe-bind')); |
82
|
|
|
|
83
|
|
|
$this->queueManager->define($this->configuration->reveal()); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|