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