1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter; |
4
|
|
|
|
5
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepoCreatedAt; |
6
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepoOwner; |
7
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepoPushedAt; |
8
|
|
|
use DevBoardLib\GithubCore\Repo\GithubRepoUpdatedAt; |
9
|
|
|
use DevBoardLib\GithubCore\User\GithubUserId; |
10
|
|
|
use PhpSpec\ObjectBehavior; |
11
|
|
|
use Prophecy\Argument; |
12
|
|
|
use tests\DevBoardLib\GithubObjectApiFacade\SampleDataProvider; |
13
|
|
|
|
14
|
|
|
class GithubRepoConverterSpec extends ObjectBehavior |
15
|
|
|
{ |
16
|
|
|
public function it_is_initializable() |
17
|
|
|
{ |
18
|
|
|
$this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter\GithubRepoConverter'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function let() |
22
|
|
|
{ |
23
|
|
|
$this->beConstructedWith(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @dataProvider provideRepoDetails |
28
|
|
|
*/ |
29
|
|
|
public function it_returns_github_repo_source_as_result($arrayData) |
30
|
|
|
{ |
31
|
|
|
$result = $this->convert($arrayData); |
32
|
|
|
$result->shouldReturnAnInstanceOf('DevBoardLib\GithubCore\Repo\GithubRepoSource'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @dataProvider provideRepoDetails |
37
|
|
|
*/ |
38
|
|
|
public function it_will_hold_repo_id_in_result($arrayData) |
39
|
|
|
{ |
40
|
|
|
$result = $this->convert($arrayData); |
41
|
|
|
$result->getId()->shouldReturnAnInstanceOf('DevBoardLib\GithubCore\Repo\GithubRepoId'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @dataProvider provideRepoDetails |
46
|
|
|
*/ |
47
|
|
|
public function it_will_hold_owner_in_result($arrayData) |
48
|
|
|
{ |
49
|
|
|
$result = $this->convert($arrayData); |
50
|
|
|
$result->getOwnerUserId()->shouldReturnAnInstanceOf(GithubUserId::class); |
51
|
|
|
$result->getOwner()->shouldReturnAnInstanceOf(GithubRepoOwner::class); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @dataProvider provideRepoDetails |
56
|
|
|
*/ |
57
|
|
|
public function it_will_hold_repo_name_in_result($arrayData) |
58
|
|
|
{ |
59
|
|
|
$result = $this->convert($arrayData); |
60
|
|
|
$result->getName()->__toString()->shouldReturn($arrayData['name']); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @dataProvider provideRepoDetails |
65
|
|
|
*/ |
66
|
|
|
public function it_will_hold_repo_full_name_in_result($arrayData) |
67
|
|
|
{ |
68
|
|
|
$result = $this->convert($arrayData); |
69
|
|
|
$result->getFullName()->__toString()->shouldReturn($arrayData['full_name']); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @dataProvider provideRepoDetails |
74
|
|
|
*/ |
75
|
|
|
public function it_will_hold_url_to_github_page_in_result($arrayData) |
76
|
|
|
{ |
77
|
|
|
$result = $this->convert($arrayData); |
78
|
|
|
$result->getHtmlUrl()->shouldReturn($arrayData['html_url']); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @dataProvider provideRepoDetails |
83
|
|
|
*/ |
84
|
|
|
public function it_will_hold_repo_description_in_result($arrayData) |
85
|
|
|
{ |
86
|
|
|
$result = $this->convert($arrayData); |
87
|
|
|
$result->getDescription()->shouldReturn($arrayData['description']); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @dataProvider provideRepoDetails |
92
|
|
|
*/ |
93
|
|
|
public function it_will_hold_if_repo_is_a_fork_in_result($arrayData) |
94
|
|
|
{ |
95
|
|
|
$result = $this->convert($arrayData); |
96
|
|
|
$result->isFork()->shouldReturn($arrayData['fork']); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @dataProvider provideRepoDetails |
101
|
|
|
*/ |
102
|
|
|
public function it_will_hold_default_branch_name_in_result($arrayData) |
103
|
|
|
{ |
104
|
|
|
$result = $this->convert($arrayData); |
105
|
|
|
$result->getDefaultBranchName()->shouldReturn($arrayData['default_branch']); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @dataProvider provideRepoDetails |
110
|
|
|
*/ |
111
|
|
|
public function it_will_hold_if_repo_is_private_in_result($arrayData) |
112
|
|
|
{ |
113
|
|
|
$result = $this->convert($arrayData); |
114
|
|
|
$result->isPrivate()->shouldReturn($arrayData['private']); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @dataProvider provideRepoDetails |
119
|
|
|
*/ |
120
|
|
|
public function it_will_hold_git_clone_url_in_result($arrayData) |
121
|
|
|
{ |
122
|
|
|
$result = $this->convert($arrayData); |
123
|
|
|
$result->getGitUrl()->__toString()->shouldReturn($arrayData['git_url']); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @dataProvider provideRepoDetails |
128
|
|
|
*/ |
129
|
|
|
public function it_will_hold_ssh_clone_url_in_result($arrayData) |
130
|
|
|
{ |
131
|
|
|
$result = $this->convert($arrayData); |
132
|
|
|
$result->getSshUrl()->__toString()->shouldReturn($arrayData['ssh_url']); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @dataProvider provideRepoDetails |
137
|
|
|
*/ |
138
|
|
|
public function it_will_have_github_created_datetime_in_converted_result($arrayData) |
139
|
|
|
{ |
140
|
|
|
$result = $this->convert($arrayData); |
141
|
|
|
|
142
|
|
|
$result->getGithubCreatedAt()->shouldBeAnInstanceOf(GithubRepoCreatedAt::class); |
143
|
|
|
$result->getGithubCreatedAt()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['created_at']); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @dataProvider provideRepoDetails |
148
|
|
|
*/ |
149
|
|
|
public function it_will_have_github_last_updated_datetime_in_converted_result($arrayData) |
150
|
|
|
{ |
151
|
|
|
$result = $this->convert($arrayData); |
152
|
|
|
|
153
|
|
|
$result->getGithubUpdatedAt()->shouldBeAnInstanceOf(GithubRepoUpdatedAt::class); |
154
|
|
|
$result->getGithubUpdatedAt()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['updated_at']); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @dataProvider provideRepoDetails |
159
|
|
|
*/ |
160
|
|
|
public function it_will_have_github_last_pushed_datetime_in_converted_result($arrayData) |
161
|
|
|
{ |
162
|
|
|
$result = $this->convert($arrayData); |
163
|
|
|
|
164
|
|
|
$result->getGithubPushedAt()->shouldBeAnInstanceOf(GithubRepoPushedAt::class); |
165
|
|
|
$result->getGithubPushedAt()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['pushed_at']); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function provideRepoDetails() |
169
|
|
|
{ |
170
|
|
|
return [ |
171
|
|
|
[$this->getDataProvider()->getRepoDetails()], |
172
|
|
|
]; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
protected function getDataProvider() |
176
|
|
|
{ |
177
|
|
|
return new SampleDataProvider(); |
178
|
|
|
} |
179
|
|
|
} |
180
|
|
|
|