Completed
Push — master ( 627c37...9fcd11 )
by Olivier
03:49 queued 01:55
created

VhostManagerTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 50
rs 10
1
<?php
2
3
namespace Ola\RabbitMqAdminToolkitBundle\Tests\Manager;
4
5
use Ola\RabbitMqAdminToolkitBundle\Manager\VhostManager;
6
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