Completed
Push — master ( 12f683...a4b1f6 )
by Miro
02:18
created

it_holds_milestone_state()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace spec\DevBoardLib\GithubObjectApiFacade\Repo\Milestone;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Milestone\GithubMilestoneId;
6
use DevBoardLib\GithubCore\Milestone\State\GithubMilestoneClosedState;
7
use DevBoardLib\GithubCore\Milestone\State\GithubMilestoneOpenState;
8
use DevBoardLib\GithubCore\Repo\GithubRepo;
9
use DevBoardLib\GithubCore\Repo\GithubRepoId;
10
use DevBoardLib\GithubCore\User\GithubUser;
11
use DevBoardLib\GithubCore\User\GithubUserId;
12
use PhpSpec\ObjectBehavior;
13
use Prophecy\Argument;
14
15
class GithubMilestoneSourceSpec extends ObjectBehavior
16
{
17
    public function it_is_initializable()
18
    {
19
        $this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\Milestone\GithubMilestoneSource');
20
        $this->shouldHaveType('DevBoardLib\GithubCore\Milestone\GithubMilestone');
21
    }
22
23
    public function let(
24
        GithubMilestoneId $id,
25
        GithubRepo $repo,
26
        GithubUser $createdByUser,
27
        DateTime $dueDate,
28
        DateTime $githubCreatedAt,
29
        DateTime $githubUpdatedAt,
30
        DateTime $githubClosedAt
31
    ) {
32
        $this->beConstructedWith(
33
            $id,
34
            $repo,
35
            22,
36
            new GithubMilestoneOpenState(),
37
            'Milestone title',
38
            'Milestone desc ...',
39
            $createdByUser,
40
            32,
41
            43,
42
            $dueDate,
43
            $githubCreatedAt,
44
            $githubUpdatedAt,
45
            $githubClosedAt
46
        );
47
    }
48
49
    public function it_can_be_constructed_without_due_date(
50
        $id,
51
        $repo,
52
        $createdByUser,
53
        $githubCreatedAt,
54
        $githubUpdatedAt,
55
        DateTime $githubClosedAt
56
    ) {
57
        $this->beConstructedWith(
58
            $id,
59
            $repo,
60
            22,
61
            new GithubMilestoneClosedState(),
62
            'title',
63
            'desc ...',
64
            $createdByUser,
65
            32,
66
            43,
67
            null,
68
            $githubCreatedAt,
69
            $githubUpdatedAt,
70
            $githubClosedAt
71
        );
72
    }
73
74
    public function it_has_github_id_as_primary_key($id)
75
    {
76
        $this->getId()->shouldReturn($id);
77
    }
78
79
    public function it_holds_repo_it_belongs_to($repo, GithubRepoId $repoId)
80
    {
81
        $repo->getId()->willReturn($repoId);
82
83
        $this->getRepoId()->shouldReturn($repoId);
84
    }
85
86
    public function it_holds_milestone_number()
87
    {
88
        $this->getNumber()->shouldReturn(22);
89
    }
90
91
    public function it_holds_milestone_state()
92
    {
93
        $this->getState()
94
            ->shouldReturnAnInstanceOf('DevBoardLib\GithubCore\Milestone\State\GithubMilestoneState');
95
    }
96
97
    public function it_holds_title()
98
    {
99
        $this->getTitle()->shouldReturn('Milestone title');
100
    }
101
102
    public function it_holds_body()
103
    {
104
        $this->getDescription()->shouldReturn('Milestone desc ...');
105
    }
106
107
    public function it_knows_who_created_milestone($createdByUser, GithubUserId $createdByUserId)
108
    {
109
        $createdByUser->getGithubUserId()->willReturn($createdByUserId);
110
        $this->getCreatedByUserId()->shouldReturn($createdByUserId);
111
    }
112
113
    public function it_knows_open_issue_count()
114
    {
115
        $this->getOpenIssueCount()->shouldReturn(32);
116
    }
117
118
    public function it_knows_closed_issue_count()
119
    {
120
        $this->getClosedIssueCount()->shouldReturn(43);
121
    }
122
123
    public function it_knows_time_when_milestone_is_due($dueDate)
124
    {
125
        $this->getDueDate()->shouldReturn($dueDate);
126
    }
127
128
    public function it_knows_time_when_created_on_github($githubCreatedAt)
129
    {
130
        $this->getGithubCreatedAt()->shouldReturn($githubCreatedAt);
131
    }
132
133
    public function it_knows_time_when_last_updated_on_github($githubUpdatedAt)
134
    {
135
        $this->getGithubUpdatedAt()->shouldReturn($githubUpdatedAt);
136
    }
137
138
    public function it_knows_time_when_milestone_was_closed($githubClosedAt)
139
    {
140
        $this->getGithubClosedAt()->shouldReturn($githubClosedAt);
141
    }
142
}
143