1 | <?php |
||
7 | class VhostManagerTest extends AbstractManagerTest |
||
8 | { |
||
9 | private $vhosts; |
||
10 | |||
11 | private $vhostManager; |
||
12 | |||
13 | public function setUp() |
||
14 | { |
||
15 | parent::setUp(); |
||
16 | |||
17 | $this->vhosts = $this->prophesize('RabbitMq\ManagementApi\Api\Vhost'); |
||
18 | $this->client->vhosts()->willReturn($this->vhosts->reveal()); |
||
19 | |||
20 | $this->vhostManager = new VhostManager(); |
||
21 | } |
||
22 | |||
23 | public function test_exists_doNotExists() |
||
24 | { |
||
25 | $exception = $this->get404Exception(); |
||
26 | $this->vhosts->get('vhost')->willThrow($exception->reveal()); |
||
27 | |||
28 | $this->assertFalse($this->vhostManager->exists($this->configuration->reveal())); |
||
29 | } |
||
30 | |||
31 | public function test_exists() |
||
32 | { |
||
33 | $this->vhosts->get('vhost')->willReturn(array('vhost')); |
||
34 | |||
35 | $this->assertTrue($this->vhostManager->exists($this->configuration->reveal())); |
||
36 | } |
||
37 | |||
38 | public function test_define_create() |
||
39 | { |
||
40 | $exception = $this->get404Exception(); |
||
41 | $this->vhosts->get('vhost')->willThrow($exception->reveal()); |
||
42 | |||
43 | $this->vhosts->create('vhost')->shouldBeCalled(); |
||
44 | |||
45 | $this->vhostManager->define($this->configuration->reveal()); |
||
46 | } |
||
47 | |||
48 | public function test_define_vhostExists() |
||
49 | { |
||
50 | $this->vhosts->get('vhost')->willReturn(array()); |
||
51 | |||
52 | $this->vhosts->create('vhost')->shouldNotBeCalled(); |
||
53 | |||
54 | $this->vhostManager->define($this->configuration->reveal()); |
||
55 | } |
||
56 | } |
||
57 |