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

TenantSpec   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

15 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_implements_tenant_interface() 0 4 1
A it_has_no_id_by_default() 0 4 1
A it_has_no_name_by_default() 0 4 1
A it_has_no_subdomain_by_default() 0 4 1
A it_is_enabled_by_default() 0 4 1
A it_can_be_disabled() 0 5 1
A it_should_initialize_creation_date_by_default() 0 4 1
A its_creation_date_is_mutable() 0 5 1
A it_has_no_last_update_date_by_default() 0 4 1
A its_last_update_date_is_mutable() 0 5 1
A it_doesnt_have_fluent_interface() 0 6 1
A it_should_return_true_if_tenant_is_deleted() 0 6 1
A it_should_return_false_if_tenant_is_not_deleted() 0 4 1
A it_has_no_deleted_at_date_by_default() 0 4 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\Model;
15
16
use PhpSpec\ObjectBehavior;
17
18
class TenantSpec extends ObjectBehavior
19
{
20
    public function it_is_initializable()
21
    {
22
        $this->shouldHaveType('SWP\Component\MultiTenancy\Model\Tenant');
23
    }
24
25
    public function it_implements_tenant_interface()
26
    {
27
        $this->shouldImplement('SWP\Component\MultiTenancy\Model\TenantInterface');
28
    }
29
30
    public function it_has_no_id_by_default()
31
    {
32
        $this->getId()->shouldReturn(null);
33
    }
34
35
    public function it_has_no_name_by_default()
36
    {
37
        $this->getName()->shouldReturn(null);
38
    }
39
40
    public function it_has_no_subdomain_by_default()
41
    {
42
        $this->getSubdomain()->shouldReturn(null);
43
    }
44
45
    public function it_is_enabled_by_default()
46
    {
47
        $this->shouldBeEnabled();
48
    }
49
50
    public function it_can_be_disabled()
51
    {
52
        $this->setEnabled(false);
53
        $this->shouldNotBeEnabled();
54
    }
55
56
    public function it_should_initialize_creation_date_by_default()
57
    {
58
        $this->getCreatedAt()->shouldHaveType('DateTime');
59
    }
60
61
    public function its_creation_date_is_mutable(\DateTime $date)
62
    {
63
        $this->setCreatedAt($date);
64
        $this->getCreatedAt()->shouldReturn($date);
65
    }
66
67
    public function it_has_no_last_update_date_by_default()
68
    {
69
        $this->getUpdatedAt()->shouldReturn(null);
70
    }
71
72
    public function its_last_update_date_is_mutable(\DateTime $date)
73
    {
74
        $this->setUpdatedAt($date);
75
        $this->getUpdatedAt()->shouldReturn($date);
76
    }
77
78
    public function it_doesnt_have_fluent_interface()
79
    {
80
        $this->setId(1)->shouldNotReturn($this);
81
        $this->setName('Tenant 1')->shouldNotReturn($this);
82
        $this->setSubdomain('client1')->shouldNotReturn($this);
83
    }
84
85
    public function it_should_return_true_if_tenant_is_deleted()
86
    {
87
        $deletedAt = new \DateTime('yesterday');
88
        $this->setDeletedAt($deletedAt);
89
        $this->shouldBeDeleted();
90
    }
91
92
    public function it_should_return_false_if_tenant_is_not_deleted()
93
    {
94
        $this->shouldNotBeDeleted();
95
    }
96
97
    public function it_has_no_deleted_at_date_by_default()
98
    {
99
        $this->getDeletedAt()->shouldReturn(null);
100
    }
101
}
102