Completed
Pull Request — master (#1)
by Rafał
22:28
created

TenantProviderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 39
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_tenant_provider_interface() 0 4 1
A it_provides_an_array_of_all_available_tenants() 0 21 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Component.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace spec\SWP\Component\MultiTenancy\Provider;
15
16
use PhpSpec\ObjectBehavior;
17
use SWP\Component\MultiTenancy\Repository\TenantRepositoryInterface;
18
19
class TenantProviderSpec extends ObjectBehavior
20
{
21
    public function let(TenantRepositoryInterface $tenantRepository)
22
    {
23
        $this->beConstructedWith($tenantRepository);
24
    }
25
26
    public function it_is_initializable()
27
    {
28
        $this->shouldHaveType('SWP\Component\MultiTenancy\Provider\TenantProvider');
29
    }
30
31
    public function it_implements_tenant_provider_interface()
32
    {
33
        $this->shouldImplement('SWP\Component\MultiTenancy\Provider\TenantProviderInterface');
34
    }
35
36
    public function it_provides_an_array_of_all_available_tenants($tenantRepository)
37
    {
38
        $tenants = array(
39
            0 => array(
40
                'id' => 1,
41
                'name' => 'test name',
42
                'subdomain' => 'example1',
43
            ),
44
            1 => array(
45
                'id' => 2,
46
                'name' => 'test name 2',
47
                'subdomain' => 'example2',
48
            ),
49
        );
50
51
        $tenantRepository->findAvailableTenants()
52
            ->shouldBeCalled()
53
            ->willReturn($tenants);
54
55
        $this->getAvailableTenants()->shouldReturn($tenants);
56
    }
57
}
58