@@ -11,19 +11,19 @@ |
||
11 | 11 | */ |
12 | 12 | class WebHookTest extends AbstractWebHookTest |
13 | 13 | { |
14 | - /** |
|
15 | - * Test instance of WebHook's class |
|
16 | - */ |
|
17 | - public function testWebHook() |
|
18 | - { |
|
19 | - $this->assertInstanceOf(WebHook::class, $this->webHook); |
|
20 | - } |
|
14 | + /** |
|
15 | + * Test instance of WebHook's class |
|
16 | + */ |
|
17 | + public function testWebHook() |
|
18 | + { |
|
19 | + $this->assertInstanceOf(WebHook::class, $this->webHook); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Test instance of Payload's class |
|
24 | - */ |
|
25 | - public function testPayload() |
|
26 | - { |
|
27 | - $this->assertInstanceOf(Payload::class, $this->payload); |
|
28 | - } |
|
22 | + /** |
|
23 | + * Test instance of Payload's class |
|
24 | + */ |
|
25 | + public function testPayload() |
|
26 | + { |
|
27 | + $this->assertInstanceOf(Payload::class, $this->payload); |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -12,320 +12,320 @@ |
||
12 | 12 | */ |
13 | 13 | class ActivityTest extends AbstractClientTest |
14 | 14 | { |
15 | - /** @var Activity\Events */ |
|
16 | - protected $events; |
|
17 | - |
|
18 | - /** @var Activity\Feeds */ |
|
19 | - protected $feeds; |
|
20 | - |
|
21 | - /** @var Activity\Notifications */ |
|
22 | - protected $notifications; |
|
23 | - |
|
24 | - /** @var Activity\Starring */ |
|
25 | - protected $starring; |
|
26 | - |
|
27 | - /** @var Activity\Watching */ |
|
28 | - protected $watching; |
|
29 | - |
|
30 | - /** |
|
31 | - * ActivityTest constructor. |
|
32 | - * |
|
33 | - * @param null $name |
|
34 | - * @param array $data |
|
35 | - * @param string $dataName |
|
36 | - */ |
|
37 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
38 | - { |
|
39 | - parent::__construct($name, $data, $dataName); |
|
40 | - |
|
41 | - // Activity |
|
42 | - $activity = $this->client->getReceiver(Client::ACTIVITY); |
|
43 | - $activity->setRepo('GitHubAPI'); |
|
44 | - $activity->setOwner('FlexyProject'); |
|
45 | - |
|
46 | - // Events |
|
47 | - $this->events = $activity->getReceiver(Activity::EVENTS); |
|
48 | - |
|
49 | - // Feeds |
|
50 | - $this->feeds = $activity->getReceiver(Activity::FEEDS); |
|
51 | - |
|
52 | - // Notifications |
|
53 | - $this->notifications = $activity->getReceiver(Activity::NOTIFICATIONS); |
|
54 | - |
|
55 | - // Starring |
|
56 | - $this->starring = $activity->getReceiver(Activity::STARRING); |
|
57 | - |
|
58 | - // Watching |
|
59 | - $this->watching = $activity->getReceiver(Activity::WATCHING); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Test instance of Events's class |
|
64 | - */ |
|
65 | - public function testEvents() |
|
66 | - { |
|
67 | - $this->assertInstanceOf(Activity\Events::class, $this->events); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Test instance of Feeds's class |
|
72 | - */ |
|
73 | - public function testFeeds() |
|
74 | - { |
|
75 | - $this->assertInstanceOf(Activity\Feeds::class, $this->feeds); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Test instance of Notifications's class |
|
80 | - */ |
|
81 | - public function testNotifications() |
|
82 | - { |
|
83 | - $this->assertInstanceOf(Activity\Notifications::class, $this->notifications); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Test instance of Starring's class |
|
88 | - */ |
|
89 | - public function testStarring() |
|
90 | - { |
|
91 | - $this->assertInstanceOf(Activity\Starring::class, $this->starring); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Test instance of Watching's class |
|
96 | - */ |
|
97 | - public function testWatching() |
|
98 | - { |
|
99 | - $this->assertInstanceOf(Activity\Watching::class, $this->watching); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Test listing public events |
|
104 | - */ |
|
105 | - public function testListPublicEvents() |
|
106 | - { |
|
107 | - $events = $this->events->listPublicEvents(); |
|
108 | - if (!empty($events)) { |
|
109 | - $event = array_pop($events); |
|
110 | - |
|
111 | - $this->assertArrayHasKey('id', $event); |
|
112 | - $this->assertArrayHasKey('type', $event); |
|
113 | - $this->assertArrayHasKey('actor', $event); |
|
114 | - $this->assertArrayHasKey('repo', $event); |
|
115 | - $this->assertArrayHasKey('payload', $event); |
|
116 | - $this->assertArrayHasKey('public', $event); |
|
117 | - $this->assertArrayHasKey('created_at', $event); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Test listing repository events |
|
123 | - */ |
|
124 | - public function testListRepositoryEvents() |
|
125 | - { |
|
126 | - $events = $this->events->listRepositoryEvents(); |
|
127 | - if (!empty($events)) { |
|
128 | - $event = array_pop($events); |
|
129 | - |
|
130 | - $this->assertArrayHasKey('id', $event); |
|
131 | - $this->assertArrayHasKey('type', $event); |
|
132 | - $this->assertArrayHasKey('actor', $event); |
|
133 | - $this->assertArrayHasKey('repo', $event); |
|
134 | - $this->assertArrayHasKey('payload', $event); |
|
135 | - $this->assertArrayHasKey('public', $event); |
|
136 | - $this->assertArrayHasKey('created_at', $event); |
|
137 | - $this->assertArrayHasKey('org', $event); |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Test listing issues events |
|
143 | - */ |
|
144 | - public function testListIssueEvents() |
|
145 | - { |
|
146 | - $events = $this->events->listIssueEvents(); |
|
147 | - if (!empty($events)) { |
|
148 | - $event = array_pop($events); |
|
149 | - |
|
150 | - $this->assertArrayHasKey('id', $event); |
|
151 | - $this->assertArrayHasKey('url', $event); |
|
152 | - $this->assertArrayHasKey('actor', $event); |
|
153 | - $this->assertArrayHasKey('event', $event); |
|
154 | - $this->assertArrayHasKey('issue', $event); |
|
155 | - $this->assertArrayHasKey('created_at', $event); |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Test listing public network events |
|
161 | - */ |
|
162 | - public function testListPublicNetworkEvents() |
|
163 | - { |
|
164 | - $events = $this->events->listPublicNetworkEvents(); |
|
165 | - if (!empty($events)) { |
|
166 | - $event = array_pop($events); |
|
167 | - |
|
168 | - $this->assertArrayHasKey('id', $event); |
|
169 | - $this->assertArrayHasKey('type', $event); |
|
170 | - $this->assertArrayHasKey('actor', $event); |
|
171 | - $this->assertArrayHasKey('repo', $event); |
|
172 | - $this->assertArrayHasKey('payload', $event); |
|
173 | - $this->assertArrayHasKey('public', $event); |
|
174 | - $this->assertArrayHasKey('created_at', $event); |
|
175 | - $this->assertArrayHasKey('org', $event); |
|
176 | - } |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Test listing public organization events |
|
181 | - */ |
|
182 | - public function testListPublicOrganizationEvents() |
|
183 | - { |
|
184 | - $events = $this->events->listPublicOrganizationEvents($GLOBALS['ORGANIZATION']); |
|
185 | - if (!empty($events)) { |
|
186 | - $event = array_pop($events); |
|
187 | - |
|
188 | - $this->assertArrayHasKey('id', $event); |
|
189 | - $this->assertArrayHasKey('type', $event); |
|
190 | - $this->assertArrayHasKey('actor', $event); |
|
191 | - $this->assertArrayHasKey('repo', $event); |
|
192 | - $this->assertArrayHasKey('payload', $event); |
|
193 | - $this->assertArrayHasKey('public', $event); |
|
194 | - $this->assertArrayHasKey('created_at', $event); |
|
195 | - $this->assertArrayHasKey('org', $event); |
|
196 | - } |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Test listing user receive events |
|
201 | - */ |
|
202 | - public function testListUserReceiveEvents() |
|
203 | - { |
|
204 | - $events = $this->events->listUserReceiveEvents($GLOBALS['USERNAME']); |
|
205 | - if (!empty($events)) { |
|
206 | - $event = array_pop($events); |
|
207 | - |
|
208 | - $this->assertArrayHasKey('id', $event); |
|
209 | - $this->assertArrayHasKey('type', $event); |
|
210 | - $this->assertArrayHasKey('actor', $event); |
|
211 | - $this->assertArrayHasKey('repo', $event); |
|
212 | - $this->assertArrayHasKey('payload', $event); |
|
213 | - $this->assertArrayHasKey('public', $event); |
|
214 | - $this->assertArrayHasKey('created_at', $event); |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * Test listing public user receive events |
|
220 | - */ |
|
221 | - public function testListPublicUserReceiveEvents() |
|
222 | - { |
|
223 | - $events = $this->events->listPublicUserReceiveEvents($GLOBALS['USERNAME']); |
|
224 | - if (!empty($events)) { |
|
225 | - $event = array_pop($events); |
|
226 | - |
|
227 | - $this->assertArrayHasKey('id', $event); |
|
228 | - $this->assertArrayHasKey('type', $event); |
|
229 | - $this->assertArrayHasKey('actor', $event); |
|
230 | - $this->assertArrayHasKey('repo', $event); |
|
231 | - $this->assertArrayHasKey('payload', $event); |
|
232 | - $this->assertArrayHasKey('public', $event); |
|
233 | - $this->assertArrayHasKey('created_at', $event); |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Test listing user preformed events |
|
239 | - */ |
|
240 | - public function testListUserPerformedEvents() |
|
241 | - { |
|
242 | - $events = $this->events->listUserPerformedEvents($GLOBALS['USERNAME']); |
|
243 | - if (!empty($events)) { |
|
244 | - $event = array_pop($events); |
|
245 | - |
|
246 | - $this->assertArrayHasKey('id', $event); |
|
247 | - $this->assertArrayHasKey('type', $event); |
|
248 | - $this->assertArrayHasKey('actor', $event); |
|
249 | - $this->assertArrayHasKey('repo', $event); |
|
250 | - $this->assertArrayHasKey('payload', $event); |
|
251 | - $this->assertArrayHasKey('public', $event); |
|
252 | - $this->assertArrayHasKey('created_at', $event); |
|
253 | - $this->assertArrayHasKey('org', $event); |
|
254 | - } |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Test listing public user performed events |
|
259 | - */ |
|
260 | - public function testListPublicUserPerformedEvents() |
|
261 | - { |
|
262 | - $events = $this->events->listPublicUserPerformedEvents($GLOBALS['USERNAME']); |
|
263 | - if (!empty($events)) { |
|
264 | - $event = array_pop($events); |
|
265 | - |
|
266 | - $this->assertArrayHasKey('id', $event); |
|
267 | - $this->assertArrayHasKey('type', $event); |
|
268 | - $this->assertArrayHasKey('actor', $event); |
|
269 | - $this->assertArrayHasKey('repo', $event); |
|
270 | - $this->assertArrayHasKey('payload', $event); |
|
271 | - $this->assertArrayHasKey('public', $event); |
|
272 | - $this->assertArrayHasKey('created_at', $event); |
|
273 | - $this->assertArrayHasKey('org', $event); |
|
274 | - } |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Test listing organization events |
|
279 | - */ |
|
280 | - public function testListOrganizationEvents() |
|
281 | - { |
|
282 | - $events = $this->events->listOrganizationEvents($GLOBALS['USERNAME'], $GLOBALS['ORGANIZATION']); |
|
283 | - if (!empty($events)) { |
|
284 | - $event = array_pop($events); |
|
285 | - |
|
286 | - $this->assertArrayHasKey('id', $event); |
|
287 | - $this->assertArrayHasKey('type', $event); |
|
288 | - $this->assertArrayHasKey('actor', $event); |
|
289 | - $this->assertArrayHasKey('repo', $event); |
|
290 | - $this->assertArrayHasKey('payload', $event); |
|
291 | - $this->assertArrayHasKey('public', $event); |
|
292 | - $this->assertArrayHasKey('created_at', $event); |
|
293 | - $this->assertArrayHasKey('org', $event); |
|
294 | - } |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Test listing feeds |
|
299 | - */ |
|
300 | - public function testListFeeds() |
|
301 | - { |
|
302 | - $feeds = $this->feeds->listFeeds(); |
|
303 | - $this->assertArrayHasKey('timeline_url', $feeds); |
|
304 | - $this->assertArrayHasKey('user_url', $feeds); |
|
305 | - $this->assertArrayHasKey('current_user_public_url', $feeds); |
|
306 | - $this->assertArrayHasKey('current_user_url', $feeds); |
|
307 | - $this->assertArrayHasKey('current_user_actor_url', $feeds); |
|
308 | - $this->assertArrayHasKey('current_user_organization_url', $feeds); |
|
309 | - $this->assertArrayHasKey('current_user_organization_urls', $feeds); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Test listing notifications |
|
314 | - */ |
|
315 | - public function testListNotifications() |
|
316 | - { |
|
317 | - $notifications = $this->notifications->listNotifications(true, true, '2016-02-14'); |
|
318 | - if (!empty($notifications)) { |
|
319 | - $notification = array_pop($notifications); |
|
320 | - |
|
321 | - $this->assertArrayHasKey('id', $notification); |
|
322 | - $this->assertArrayHasKey('repository', $notification); |
|
323 | - $this->assertArrayHasKey('subject', $notification); |
|
324 | - $this->assertArrayHasKey('reason', $notification); |
|
325 | - $this->assertArrayHasKey('unread', $notification); |
|
326 | - $this->assertArrayHasKey('updated_at', $notification); |
|
327 | - $this->assertArrayHasKey('last_read_at', $notification); |
|
328 | - $this->assertArrayHasKey('url', $notification); |
|
329 | - } |
|
330 | - } |
|
15 | + /** @var Activity\Events */ |
|
16 | + protected $events; |
|
17 | + |
|
18 | + /** @var Activity\Feeds */ |
|
19 | + protected $feeds; |
|
20 | + |
|
21 | + /** @var Activity\Notifications */ |
|
22 | + protected $notifications; |
|
23 | + |
|
24 | + /** @var Activity\Starring */ |
|
25 | + protected $starring; |
|
26 | + |
|
27 | + /** @var Activity\Watching */ |
|
28 | + protected $watching; |
|
29 | + |
|
30 | + /** |
|
31 | + * ActivityTest constructor. |
|
32 | + * |
|
33 | + * @param null $name |
|
34 | + * @param array $data |
|
35 | + * @param string $dataName |
|
36 | + */ |
|
37 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
38 | + { |
|
39 | + parent::__construct($name, $data, $dataName); |
|
40 | + |
|
41 | + // Activity |
|
42 | + $activity = $this->client->getReceiver(Client::ACTIVITY); |
|
43 | + $activity->setRepo('GitHubAPI'); |
|
44 | + $activity->setOwner('FlexyProject'); |
|
45 | + |
|
46 | + // Events |
|
47 | + $this->events = $activity->getReceiver(Activity::EVENTS); |
|
48 | + |
|
49 | + // Feeds |
|
50 | + $this->feeds = $activity->getReceiver(Activity::FEEDS); |
|
51 | + |
|
52 | + // Notifications |
|
53 | + $this->notifications = $activity->getReceiver(Activity::NOTIFICATIONS); |
|
54 | + |
|
55 | + // Starring |
|
56 | + $this->starring = $activity->getReceiver(Activity::STARRING); |
|
57 | + |
|
58 | + // Watching |
|
59 | + $this->watching = $activity->getReceiver(Activity::WATCHING); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Test instance of Events's class |
|
64 | + */ |
|
65 | + public function testEvents() |
|
66 | + { |
|
67 | + $this->assertInstanceOf(Activity\Events::class, $this->events); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Test instance of Feeds's class |
|
72 | + */ |
|
73 | + public function testFeeds() |
|
74 | + { |
|
75 | + $this->assertInstanceOf(Activity\Feeds::class, $this->feeds); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Test instance of Notifications's class |
|
80 | + */ |
|
81 | + public function testNotifications() |
|
82 | + { |
|
83 | + $this->assertInstanceOf(Activity\Notifications::class, $this->notifications); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Test instance of Starring's class |
|
88 | + */ |
|
89 | + public function testStarring() |
|
90 | + { |
|
91 | + $this->assertInstanceOf(Activity\Starring::class, $this->starring); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Test instance of Watching's class |
|
96 | + */ |
|
97 | + public function testWatching() |
|
98 | + { |
|
99 | + $this->assertInstanceOf(Activity\Watching::class, $this->watching); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Test listing public events |
|
104 | + */ |
|
105 | + public function testListPublicEvents() |
|
106 | + { |
|
107 | + $events = $this->events->listPublicEvents(); |
|
108 | + if (!empty($events)) { |
|
109 | + $event = array_pop($events); |
|
110 | + |
|
111 | + $this->assertArrayHasKey('id', $event); |
|
112 | + $this->assertArrayHasKey('type', $event); |
|
113 | + $this->assertArrayHasKey('actor', $event); |
|
114 | + $this->assertArrayHasKey('repo', $event); |
|
115 | + $this->assertArrayHasKey('payload', $event); |
|
116 | + $this->assertArrayHasKey('public', $event); |
|
117 | + $this->assertArrayHasKey('created_at', $event); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Test listing repository events |
|
123 | + */ |
|
124 | + public function testListRepositoryEvents() |
|
125 | + { |
|
126 | + $events = $this->events->listRepositoryEvents(); |
|
127 | + if (!empty($events)) { |
|
128 | + $event = array_pop($events); |
|
129 | + |
|
130 | + $this->assertArrayHasKey('id', $event); |
|
131 | + $this->assertArrayHasKey('type', $event); |
|
132 | + $this->assertArrayHasKey('actor', $event); |
|
133 | + $this->assertArrayHasKey('repo', $event); |
|
134 | + $this->assertArrayHasKey('payload', $event); |
|
135 | + $this->assertArrayHasKey('public', $event); |
|
136 | + $this->assertArrayHasKey('created_at', $event); |
|
137 | + $this->assertArrayHasKey('org', $event); |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Test listing issues events |
|
143 | + */ |
|
144 | + public function testListIssueEvents() |
|
145 | + { |
|
146 | + $events = $this->events->listIssueEvents(); |
|
147 | + if (!empty($events)) { |
|
148 | + $event = array_pop($events); |
|
149 | + |
|
150 | + $this->assertArrayHasKey('id', $event); |
|
151 | + $this->assertArrayHasKey('url', $event); |
|
152 | + $this->assertArrayHasKey('actor', $event); |
|
153 | + $this->assertArrayHasKey('event', $event); |
|
154 | + $this->assertArrayHasKey('issue', $event); |
|
155 | + $this->assertArrayHasKey('created_at', $event); |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Test listing public network events |
|
161 | + */ |
|
162 | + public function testListPublicNetworkEvents() |
|
163 | + { |
|
164 | + $events = $this->events->listPublicNetworkEvents(); |
|
165 | + if (!empty($events)) { |
|
166 | + $event = array_pop($events); |
|
167 | + |
|
168 | + $this->assertArrayHasKey('id', $event); |
|
169 | + $this->assertArrayHasKey('type', $event); |
|
170 | + $this->assertArrayHasKey('actor', $event); |
|
171 | + $this->assertArrayHasKey('repo', $event); |
|
172 | + $this->assertArrayHasKey('payload', $event); |
|
173 | + $this->assertArrayHasKey('public', $event); |
|
174 | + $this->assertArrayHasKey('created_at', $event); |
|
175 | + $this->assertArrayHasKey('org', $event); |
|
176 | + } |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Test listing public organization events |
|
181 | + */ |
|
182 | + public function testListPublicOrganizationEvents() |
|
183 | + { |
|
184 | + $events = $this->events->listPublicOrganizationEvents($GLOBALS['ORGANIZATION']); |
|
185 | + if (!empty($events)) { |
|
186 | + $event = array_pop($events); |
|
187 | + |
|
188 | + $this->assertArrayHasKey('id', $event); |
|
189 | + $this->assertArrayHasKey('type', $event); |
|
190 | + $this->assertArrayHasKey('actor', $event); |
|
191 | + $this->assertArrayHasKey('repo', $event); |
|
192 | + $this->assertArrayHasKey('payload', $event); |
|
193 | + $this->assertArrayHasKey('public', $event); |
|
194 | + $this->assertArrayHasKey('created_at', $event); |
|
195 | + $this->assertArrayHasKey('org', $event); |
|
196 | + } |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Test listing user receive events |
|
201 | + */ |
|
202 | + public function testListUserReceiveEvents() |
|
203 | + { |
|
204 | + $events = $this->events->listUserReceiveEvents($GLOBALS['USERNAME']); |
|
205 | + if (!empty($events)) { |
|
206 | + $event = array_pop($events); |
|
207 | + |
|
208 | + $this->assertArrayHasKey('id', $event); |
|
209 | + $this->assertArrayHasKey('type', $event); |
|
210 | + $this->assertArrayHasKey('actor', $event); |
|
211 | + $this->assertArrayHasKey('repo', $event); |
|
212 | + $this->assertArrayHasKey('payload', $event); |
|
213 | + $this->assertArrayHasKey('public', $event); |
|
214 | + $this->assertArrayHasKey('created_at', $event); |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * Test listing public user receive events |
|
220 | + */ |
|
221 | + public function testListPublicUserReceiveEvents() |
|
222 | + { |
|
223 | + $events = $this->events->listPublicUserReceiveEvents($GLOBALS['USERNAME']); |
|
224 | + if (!empty($events)) { |
|
225 | + $event = array_pop($events); |
|
226 | + |
|
227 | + $this->assertArrayHasKey('id', $event); |
|
228 | + $this->assertArrayHasKey('type', $event); |
|
229 | + $this->assertArrayHasKey('actor', $event); |
|
230 | + $this->assertArrayHasKey('repo', $event); |
|
231 | + $this->assertArrayHasKey('payload', $event); |
|
232 | + $this->assertArrayHasKey('public', $event); |
|
233 | + $this->assertArrayHasKey('created_at', $event); |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Test listing user preformed events |
|
239 | + */ |
|
240 | + public function testListUserPerformedEvents() |
|
241 | + { |
|
242 | + $events = $this->events->listUserPerformedEvents($GLOBALS['USERNAME']); |
|
243 | + if (!empty($events)) { |
|
244 | + $event = array_pop($events); |
|
245 | + |
|
246 | + $this->assertArrayHasKey('id', $event); |
|
247 | + $this->assertArrayHasKey('type', $event); |
|
248 | + $this->assertArrayHasKey('actor', $event); |
|
249 | + $this->assertArrayHasKey('repo', $event); |
|
250 | + $this->assertArrayHasKey('payload', $event); |
|
251 | + $this->assertArrayHasKey('public', $event); |
|
252 | + $this->assertArrayHasKey('created_at', $event); |
|
253 | + $this->assertArrayHasKey('org', $event); |
|
254 | + } |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Test listing public user performed events |
|
259 | + */ |
|
260 | + public function testListPublicUserPerformedEvents() |
|
261 | + { |
|
262 | + $events = $this->events->listPublicUserPerformedEvents($GLOBALS['USERNAME']); |
|
263 | + if (!empty($events)) { |
|
264 | + $event = array_pop($events); |
|
265 | + |
|
266 | + $this->assertArrayHasKey('id', $event); |
|
267 | + $this->assertArrayHasKey('type', $event); |
|
268 | + $this->assertArrayHasKey('actor', $event); |
|
269 | + $this->assertArrayHasKey('repo', $event); |
|
270 | + $this->assertArrayHasKey('payload', $event); |
|
271 | + $this->assertArrayHasKey('public', $event); |
|
272 | + $this->assertArrayHasKey('created_at', $event); |
|
273 | + $this->assertArrayHasKey('org', $event); |
|
274 | + } |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Test listing organization events |
|
279 | + */ |
|
280 | + public function testListOrganizationEvents() |
|
281 | + { |
|
282 | + $events = $this->events->listOrganizationEvents($GLOBALS['USERNAME'], $GLOBALS['ORGANIZATION']); |
|
283 | + if (!empty($events)) { |
|
284 | + $event = array_pop($events); |
|
285 | + |
|
286 | + $this->assertArrayHasKey('id', $event); |
|
287 | + $this->assertArrayHasKey('type', $event); |
|
288 | + $this->assertArrayHasKey('actor', $event); |
|
289 | + $this->assertArrayHasKey('repo', $event); |
|
290 | + $this->assertArrayHasKey('payload', $event); |
|
291 | + $this->assertArrayHasKey('public', $event); |
|
292 | + $this->assertArrayHasKey('created_at', $event); |
|
293 | + $this->assertArrayHasKey('org', $event); |
|
294 | + } |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Test listing feeds |
|
299 | + */ |
|
300 | + public function testListFeeds() |
|
301 | + { |
|
302 | + $feeds = $this->feeds->listFeeds(); |
|
303 | + $this->assertArrayHasKey('timeline_url', $feeds); |
|
304 | + $this->assertArrayHasKey('user_url', $feeds); |
|
305 | + $this->assertArrayHasKey('current_user_public_url', $feeds); |
|
306 | + $this->assertArrayHasKey('current_user_url', $feeds); |
|
307 | + $this->assertArrayHasKey('current_user_actor_url', $feeds); |
|
308 | + $this->assertArrayHasKey('current_user_organization_url', $feeds); |
|
309 | + $this->assertArrayHasKey('current_user_organization_urls', $feeds); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Test listing notifications |
|
314 | + */ |
|
315 | + public function testListNotifications() |
|
316 | + { |
|
317 | + $notifications = $this->notifications->listNotifications(true, true, '2016-02-14'); |
|
318 | + if (!empty($notifications)) { |
|
319 | + $notification = array_pop($notifications); |
|
320 | + |
|
321 | + $this->assertArrayHasKey('id', $notification); |
|
322 | + $this->assertArrayHasKey('repository', $notification); |
|
323 | + $this->assertArrayHasKey('subject', $notification); |
|
324 | + $this->assertArrayHasKey('reason', $notification); |
|
325 | + $this->assertArrayHasKey('unread', $notification); |
|
326 | + $this->assertArrayHasKey('updated_at', $notification); |
|
327 | + $this->assertArrayHasKey('last_read_at', $notification); |
|
328 | + $this->assertArrayHasKey('url', $notification); |
|
329 | + } |
|
330 | + } |
|
331 | 331 | } |
332 | 332 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace FlexyProject\GitHub\Tests\Receiver; |
3 | 3 | |
4 | 4 | use FlexyProject\GitHub\{ |
5 | - Client, Receiver\Gists, Tests\AbstractClientTest |
|
5 | + Client, Receiver\Gists, Tests\AbstractClientTest |
|
6 | 6 | }; |
7 | 7 | |
8 | 8 | /** |
@@ -12,343 +12,343 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GistsTest extends AbstractClientTest |
14 | 14 | { |
15 | - /** Public test gist ID */ |
|
16 | - const PUBLIC_GIST = '76e253825bb3c6c084cf31f92997eb72'; |
|
17 | - |
|
18 | - /** @var Gists */ |
|
19 | - protected $gists; |
|
20 | - |
|
21 | - /** @var Gists\Comments */ |
|
22 | - protected $comments; |
|
23 | - |
|
24 | - /** |
|
25 | - * GistsTest constructor. |
|
26 | - * |
|
27 | - * @param null $name |
|
28 | - * @param array $data |
|
29 | - * @param string $dataName |
|
30 | - */ |
|
31 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
32 | - { |
|
33 | - parent::__construct($name, $data, $dataName); |
|
34 | - |
|
35 | - // Gists |
|
36 | - $this->gists = $this->client->getReceiver(Client::GISTS); |
|
37 | - |
|
38 | - // Comments |
|
39 | - $this->comments = $this->gists->getReceiver(Gists::COMMENTS); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Test instance of Gists's class |
|
44 | - */ |
|
45 | - public function testGists() |
|
46 | - { |
|
47 | - $this->assertInstanceOf(Gists::class, $this->gists); |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Test instance of Comments's class |
|
52 | - */ |
|
53 | - public function testComments() |
|
54 | - { |
|
55 | - $this->assertInstanceOf(Gists\Comments::class, $this->comments); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Test list gists of current users |
|
60 | - */ |
|
61 | - public function testListGists() |
|
62 | - { |
|
63 | - $gists = $this->gists->listGists(); |
|
64 | - if (!empty($gists)) { |
|
65 | - $gist = array_pop($gists); |
|
66 | - |
|
67 | - $this->assertArrayHasKey('url', $gist); |
|
68 | - $this->assertArrayHasKey('files', $gist); |
|
69 | - $this->assertArrayHasKey('comments', $gist); |
|
70 | - $this->assertArrayHasKey('created_at', $gist); |
|
71 | - $this->assertArrayHasKey('updated_at', $gist); |
|
72 | - $this->assertArrayHasKey('user', $gist); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Test list public gists |
|
78 | - */ |
|
79 | - public function testPublicListGists() |
|
80 | - { |
|
81 | - $gists = $this->gists->listPublicGists(); |
|
82 | - if (!empty($gists)) { |
|
83 | - $gist = array_pop($gists); |
|
84 | - |
|
85 | - $this->assertArrayHasKey('url', $gist); |
|
86 | - $this->assertArrayHasKey('files', $gist); |
|
87 | - $this->assertArrayHasKey('comments', $gist); |
|
88 | - $this->assertArrayHasKey('created_at', $gist); |
|
89 | - $this->assertArrayHasKey('updated_at', $gist); |
|
90 | - $this->assertArrayHasKey('user', $gist); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Test list user's starred gists |
|
96 | - */ |
|
97 | - public function testListUsersStarredGists() |
|
98 | - { |
|
99 | - $gists = $this->gists->listUsersStarredGists(); |
|
100 | - if (!empty($gists)) { |
|
101 | - $gist = array_pop($gists); |
|
102 | - |
|
103 | - $this->assertArrayHasKey('url', $gist); |
|
104 | - $this->assertArrayHasKey('files', $gist); |
|
105 | - $this->assertArrayHasKey('comments', $gist); |
|
106 | - $this->assertArrayHasKey('created_at', $gist); |
|
107 | - $this->assertArrayHasKey('updated_at', $gist); |
|
108 | - $this->assertArrayHasKey('user', $gist); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Test creating a new gist |
|
114 | - * |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - public function testCreateGist(): string |
|
118 | - { |
|
119 | - $gist = $this->gists->createGist([ |
|
120 | - md5('phpunit-testing') . '.txt' => [ |
|
121 | - 'content' => 'String file contents' |
|
122 | - ] |
|
123 | - ], 'the description for this gist'); |
|
124 | - |
|
125 | - $this->assertArrayHasKey('url', $gist); |
|
126 | - $this->assertArrayHasKey('files', $gist); |
|
127 | - $this->assertArrayHasKey('comments', $gist); |
|
128 | - $this->assertArrayHasKey('created_at', $gist); |
|
129 | - $this->assertArrayHasKey('updated_at', $gist); |
|
130 | - $this->assertArrayHasKey('user', $gist); |
|
131 | - |
|
132 | - return $gist['id']; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Test getting gist by ID |
|
137 | - * |
|
138 | - * @depends testCreateGist |
|
139 | - * |
|
140 | - * @param string $gistId |
|
141 | - */ |
|
142 | - public function testGetGistById(string $gistId) |
|
143 | - { |
|
144 | - $gist = $this->gists->getGist($gistId); |
|
145 | - |
|
146 | - $this->assertArrayHasKey('url', $gist); |
|
147 | - $this->assertArrayHasKey('files', $gist); |
|
148 | - $this->assertArrayHasKey('comments', $gist); |
|
149 | - $this->assertArrayHasKey('created_at', $gist); |
|
150 | - $this->assertArrayHasKey('updated_at', $gist); |
|
151 | - $this->assertArrayHasKey('user', $gist); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Test updating an existing gist |
|
156 | - * |
|
157 | - * @depends testCreateGist |
|
158 | - * |
|
159 | - * @param string $gistId |
|
160 | - */ |
|
161 | - public function testUpdateGist(string $gistId) |
|
162 | - { |
|
163 | - $gist = $this->gists->editGist($gistId, 'the description UPDATED for this gist', [ |
|
164 | - md5('phpunit-testing') . '.txt' => [ |
|
165 | - 'content' => 'String file contents' |
|
166 | - ] |
|
167 | - ], 'content', 'renamed-file.name'); |
|
168 | - |
|
169 | - $this->assertEquals('the description UPDATED for this gist', $gist['description']); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Test list commits of a gist |
|
174 | - * |
|
175 | - * @depends testCreateGist |
|
176 | - * |
|
177 | - * @param string $gistId |
|
178 | - */ |
|
179 | - public function testListGistsCommit(string $gistId) |
|
180 | - { |
|
181 | - $gists = $this->gists->listGistsCommits($gistId); |
|
182 | - $gist = array_pop($gists); |
|
183 | - |
|
184 | - $this->assertArrayHasKey('user', $gist); |
|
185 | - $this->assertArrayHasKey('version', $gist); |
|
186 | - $this->assertArrayHasKey('committed_at', $gist); |
|
187 | - $this->assertArrayHasKey('change_status', $gist); |
|
188 | - $this->assertArrayHasKey('url', $gist); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Test starring a gist |
|
193 | - * |
|
194 | - * @depends testCreateGist |
|
195 | - * |
|
196 | - * @param string $gistId |
|
197 | - */ |
|
198 | - public function testStarGist(string $gistId) |
|
199 | - { |
|
200 | - $this->assertTrue($this->gists->starGist($gistId)); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Test gist is starred |
|
205 | - * |
|
206 | - * @depends testCreateGist |
|
207 | - * |
|
208 | - * @param string $gistId |
|
209 | - */ |
|
210 | - public function testGistIsStarred(string $gistId) |
|
211 | - { |
|
212 | - $this->assertTrue($this->gists->checkGistIsStarred($gistId)); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Test unstar a gist |
|
217 | - * |
|
218 | - * @depends testCreateGist |
|
219 | - * |
|
220 | - * @param string $gistId |
|
221 | - */ |
|
222 | - public function testUnStarGist(string $gistId) |
|
223 | - { |
|
224 | - $this->assertTrue($this->gists->unStarGist($gistId)); |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Test fork a public gist |
|
229 | - */ |
|
230 | - public function testForkGist() |
|
231 | - { |
|
232 | - $gist = $this->gists->forkGist(self::PUBLIC_GIST); |
|
233 | - |
|
234 | - $this->assertArrayHasKey('forks_url', $gist); |
|
235 | - |
|
236 | - return $gist['id']; |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * Test list forks of a specific gist |
|
241 | - */ |
|
242 | - public function testListGistForks() |
|
243 | - { |
|
244 | - $gists = $this->gists->listGistForks(self::PUBLIC_GIST); |
|
245 | - $gist = array_pop($gists); |
|
246 | - |
|
247 | - $this->assertArrayHasKey('url', $gist); |
|
248 | - $this->assertArrayHasKey('id', $gist); |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Test deleting a forked gist |
|
253 | - * |
|
254 | - * @depends testForkGist |
|
255 | - * |
|
256 | - * @param string $gistId |
|
257 | - */ |
|
258 | - public function testDeleteForkedGist(string $gistId) |
|
259 | - { |
|
260 | - $this->assertTrue($this->gists->deleteGist($gistId)); |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * Test create a new comment in specific gist |
|
265 | - * |
|
266 | - * @depends testCreateGist |
|
267 | - * |
|
268 | - * @param string $gistId |
|
269 | - */ |
|
270 | - public function testCreateComment(string $gistId) |
|
271 | - { |
|
272 | - $response = $this->comments->createComment($gistId, 'Just commenting for the sake of commenting'); |
|
273 | - |
|
274 | - $this->assertEquals('Just commenting for the sake of commenting', $response['body']); |
|
275 | - |
|
276 | - return $response['id']; |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * Test listing all comments for specific gist |
|
281 | - * |
|
282 | - * @depends testCreateGist |
|
283 | - * |
|
284 | - * @param string $gistId |
|
285 | - */ |
|
286 | - public function testListComments(string $gistId) |
|
287 | - { |
|
288 | - $comments = $this->comments->listComments($gistId); |
|
289 | - $comment = array_pop($comments); |
|
290 | - |
|
291 | - $this->assertArrayHasKey('id', $comment); |
|
292 | - $this->assertArrayHasKey('url', $comment); |
|
293 | - $this->assertArrayHasKey('body', $comment); |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * Test getting a single comment |
|
298 | - * |
|
299 | - * @depends testCreateGist |
|
300 | - * @depends testCreateComment |
|
301 | - * |
|
302 | - * @param string $gistId |
|
303 | - * @param string $commentId |
|
304 | - */ |
|
305 | - public function testGetSingleComment(string $gistId, string $commentId) |
|
306 | - { |
|
307 | - $response = $this->comments->getSingleComment($gistId, $commentId); |
|
308 | - |
|
309 | - $this->assertEquals('Just commenting for the sake of commenting', $response['body']); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Test editing a gist's comment |
|
314 | - * |
|
315 | - * @depends testCreateGist |
|
316 | - * @depends testCreateComment |
|
317 | - * |
|
318 | - * @param string $gistId |
|
319 | - * @param string $commentId |
|
320 | - */ |
|
321 | - public function testEditComment(string $gistId, string $commentId) |
|
322 | - { |
|
323 | - $response = $this->comments->editComment($gistId, $commentId, 'Just editing this comment!'); |
|
324 | - |
|
325 | - $this->assertEquals('Just editing this comment!', $response['body']); |
|
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Test deleting a comment |
|
330 | - * |
|
331 | - * @depends testCreateGist |
|
332 | - * @depends testCreateComment |
|
333 | - * |
|
334 | - * @param string $gistId |
|
335 | - * @param string $commentId |
|
336 | - */ |
|
337 | - public function testDeleteComment(string $gistId, string $commentId) |
|
338 | - { |
|
339 | - $this->assertTrue($this->comments->deleteComment($gistId, $commentId)); |
|
340 | - } |
|
341 | - |
|
342 | - /** |
|
343 | - * Test deleting an existing gist |
|
344 | - * |
|
345 | - * @depends testCreateGist |
|
346 | - * |
|
347 | - * @param string $gistId |
|
348 | - */ |
|
349 | - public function testDeleteGist(string $gistId) |
|
350 | - { |
|
351 | - $this->assertTrue($this->gists->deleteGist($gistId)); |
|
352 | - } |
|
15 | + /** Public test gist ID */ |
|
16 | + const PUBLIC_GIST = '76e253825bb3c6c084cf31f92997eb72'; |
|
17 | + |
|
18 | + /** @var Gists */ |
|
19 | + protected $gists; |
|
20 | + |
|
21 | + /** @var Gists\Comments */ |
|
22 | + protected $comments; |
|
23 | + |
|
24 | + /** |
|
25 | + * GistsTest constructor. |
|
26 | + * |
|
27 | + * @param null $name |
|
28 | + * @param array $data |
|
29 | + * @param string $dataName |
|
30 | + */ |
|
31 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
32 | + { |
|
33 | + parent::__construct($name, $data, $dataName); |
|
34 | + |
|
35 | + // Gists |
|
36 | + $this->gists = $this->client->getReceiver(Client::GISTS); |
|
37 | + |
|
38 | + // Comments |
|
39 | + $this->comments = $this->gists->getReceiver(Gists::COMMENTS); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Test instance of Gists's class |
|
44 | + */ |
|
45 | + public function testGists() |
|
46 | + { |
|
47 | + $this->assertInstanceOf(Gists::class, $this->gists); |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Test instance of Comments's class |
|
52 | + */ |
|
53 | + public function testComments() |
|
54 | + { |
|
55 | + $this->assertInstanceOf(Gists\Comments::class, $this->comments); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Test list gists of current users |
|
60 | + */ |
|
61 | + public function testListGists() |
|
62 | + { |
|
63 | + $gists = $this->gists->listGists(); |
|
64 | + if (!empty($gists)) { |
|
65 | + $gist = array_pop($gists); |
|
66 | + |
|
67 | + $this->assertArrayHasKey('url', $gist); |
|
68 | + $this->assertArrayHasKey('files', $gist); |
|
69 | + $this->assertArrayHasKey('comments', $gist); |
|
70 | + $this->assertArrayHasKey('created_at', $gist); |
|
71 | + $this->assertArrayHasKey('updated_at', $gist); |
|
72 | + $this->assertArrayHasKey('user', $gist); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Test list public gists |
|
78 | + */ |
|
79 | + public function testPublicListGists() |
|
80 | + { |
|
81 | + $gists = $this->gists->listPublicGists(); |
|
82 | + if (!empty($gists)) { |
|
83 | + $gist = array_pop($gists); |
|
84 | + |
|
85 | + $this->assertArrayHasKey('url', $gist); |
|
86 | + $this->assertArrayHasKey('files', $gist); |
|
87 | + $this->assertArrayHasKey('comments', $gist); |
|
88 | + $this->assertArrayHasKey('created_at', $gist); |
|
89 | + $this->assertArrayHasKey('updated_at', $gist); |
|
90 | + $this->assertArrayHasKey('user', $gist); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Test list user's starred gists |
|
96 | + */ |
|
97 | + public function testListUsersStarredGists() |
|
98 | + { |
|
99 | + $gists = $this->gists->listUsersStarredGists(); |
|
100 | + if (!empty($gists)) { |
|
101 | + $gist = array_pop($gists); |
|
102 | + |
|
103 | + $this->assertArrayHasKey('url', $gist); |
|
104 | + $this->assertArrayHasKey('files', $gist); |
|
105 | + $this->assertArrayHasKey('comments', $gist); |
|
106 | + $this->assertArrayHasKey('created_at', $gist); |
|
107 | + $this->assertArrayHasKey('updated_at', $gist); |
|
108 | + $this->assertArrayHasKey('user', $gist); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Test creating a new gist |
|
114 | + * |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + public function testCreateGist(): string |
|
118 | + { |
|
119 | + $gist = $this->gists->createGist([ |
|
120 | + md5('phpunit-testing') . '.txt' => [ |
|
121 | + 'content' => 'String file contents' |
|
122 | + ] |
|
123 | + ], 'the description for this gist'); |
|
124 | + |
|
125 | + $this->assertArrayHasKey('url', $gist); |
|
126 | + $this->assertArrayHasKey('files', $gist); |
|
127 | + $this->assertArrayHasKey('comments', $gist); |
|
128 | + $this->assertArrayHasKey('created_at', $gist); |
|
129 | + $this->assertArrayHasKey('updated_at', $gist); |
|
130 | + $this->assertArrayHasKey('user', $gist); |
|
131 | + |
|
132 | + return $gist['id']; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Test getting gist by ID |
|
137 | + * |
|
138 | + * @depends testCreateGist |
|
139 | + * |
|
140 | + * @param string $gistId |
|
141 | + */ |
|
142 | + public function testGetGistById(string $gistId) |
|
143 | + { |
|
144 | + $gist = $this->gists->getGist($gistId); |
|
145 | + |
|
146 | + $this->assertArrayHasKey('url', $gist); |
|
147 | + $this->assertArrayHasKey('files', $gist); |
|
148 | + $this->assertArrayHasKey('comments', $gist); |
|
149 | + $this->assertArrayHasKey('created_at', $gist); |
|
150 | + $this->assertArrayHasKey('updated_at', $gist); |
|
151 | + $this->assertArrayHasKey('user', $gist); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Test updating an existing gist |
|
156 | + * |
|
157 | + * @depends testCreateGist |
|
158 | + * |
|
159 | + * @param string $gistId |
|
160 | + */ |
|
161 | + public function testUpdateGist(string $gistId) |
|
162 | + { |
|
163 | + $gist = $this->gists->editGist($gistId, 'the description UPDATED for this gist', [ |
|
164 | + md5('phpunit-testing') . '.txt' => [ |
|
165 | + 'content' => 'String file contents' |
|
166 | + ] |
|
167 | + ], 'content', 'renamed-file.name'); |
|
168 | + |
|
169 | + $this->assertEquals('the description UPDATED for this gist', $gist['description']); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Test list commits of a gist |
|
174 | + * |
|
175 | + * @depends testCreateGist |
|
176 | + * |
|
177 | + * @param string $gistId |
|
178 | + */ |
|
179 | + public function testListGistsCommit(string $gistId) |
|
180 | + { |
|
181 | + $gists = $this->gists->listGistsCommits($gistId); |
|
182 | + $gist = array_pop($gists); |
|
183 | + |
|
184 | + $this->assertArrayHasKey('user', $gist); |
|
185 | + $this->assertArrayHasKey('version', $gist); |
|
186 | + $this->assertArrayHasKey('committed_at', $gist); |
|
187 | + $this->assertArrayHasKey('change_status', $gist); |
|
188 | + $this->assertArrayHasKey('url', $gist); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Test starring a gist |
|
193 | + * |
|
194 | + * @depends testCreateGist |
|
195 | + * |
|
196 | + * @param string $gistId |
|
197 | + */ |
|
198 | + public function testStarGist(string $gistId) |
|
199 | + { |
|
200 | + $this->assertTrue($this->gists->starGist($gistId)); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Test gist is starred |
|
205 | + * |
|
206 | + * @depends testCreateGist |
|
207 | + * |
|
208 | + * @param string $gistId |
|
209 | + */ |
|
210 | + public function testGistIsStarred(string $gistId) |
|
211 | + { |
|
212 | + $this->assertTrue($this->gists->checkGistIsStarred($gistId)); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Test unstar a gist |
|
217 | + * |
|
218 | + * @depends testCreateGist |
|
219 | + * |
|
220 | + * @param string $gistId |
|
221 | + */ |
|
222 | + public function testUnStarGist(string $gistId) |
|
223 | + { |
|
224 | + $this->assertTrue($this->gists->unStarGist($gistId)); |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Test fork a public gist |
|
229 | + */ |
|
230 | + public function testForkGist() |
|
231 | + { |
|
232 | + $gist = $this->gists->forkGist(self::PUBLIC_GIST); |
|
233 | + |
|
234 | + $this->assertArrayHasKey('forks_url', $gist); |
|
235 | + |
|
236 | + return $gist['id']; |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * Test list forks of a specific gist |
|
241 | + */ |
|
242 | + public function testListGistForks() |
|
243 | + { |
|
244 | + $gists = $this->gists->listGistForks(self::PUBLIC_GIST); |
|
245 | + $gist = array_pop($gists); |
|
246 | + |
|
247 | + $this->assertArrayHasKey('url', $gist); |
|
248 | + $this->assertArrayHasKey('id', $gist); |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Test deleting a forked gist |
|
253 | + * |
|
254 | + * @depends testForkGist |
|
255 | + * |
|
256 | + * @param string $gistId |
|
257 | + */ |
|
258 | + public function testDeleteForkedGist(string $gistId) |
|
259 | + { |
|
260 | + $this->assertTrue($this->gists->deleteGist($gistId)); |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * Test create a new comment in specific gist |
|
265 | + * |
|
266 | + * @depends testCreateGist |
|
267 | + * |
|
268 | + * @param string $gistId |
|
269 | + */ |
|
270 | + public function testCreateComment(string $gistId) |
|
271 | + { |
|
272 | + $response = $this->comments->createComment($gistId, 'Just commenting for the sake of commenting'); |
|
273 | + |
|
274 | + $this->assertEquals('Just commenting for the sake of commenting', $response['body']); |
|
275 | + |
|
276 | + return $response['id']; |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * Test listing all comments for specific gist |
|
281 | + * |
|
282 | + * @depends testCreateGist |
|
283 | + * |
|
284 | + * @param string $gistId |
|
285 | + */ |
|
286 | + public function testListComments(string $gistId) |
|
287 | + { |
|
288 | + $comments = $this->comments->listComments($gistId); |
|
289 | + $comment = array_pop($comments); |
|
290 | + |
|
291 | + $this->assertArrayHasKey('id', $comment); |
|
292 | + $this->assertArrayHasKey('url', $comment); |
|
293 | + $this->assertArrayHasKey('body', $comment); |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * Test getting a single comment |
|
298 | + * |
|
299 | + * @depends testCreateGist |
|
300 | + * @depends testCreateComment |
|
301 | + * |
|
302 | + * @param string $gistId |
|
303 | + * @param string $commentId |
|
304 | + */ |
|
305 | + public function testGetSingleComment(string $gistId, string $commentId) |
|
306 | + { |
|
307 | + $response = $this->comments->getSingleComment($gistId, $commentId); |
|
308 | + |
|
309 | + $this->assertEquals('Just commenting for the sake of commenting', $response['body']); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Test editing a gist's comment |
|
314 | + * |
|
315 | + * @depends testCreateGist |
|
316 | + * @depends testCreateComment |
|
317 | + * |
|
318 | + * @param string $gistId |
|
319 | + * @param string $commentId |
|
320 | + */ |
|
321 | + public function testEditComment(string $gistId, string $commentId) |
|
322 | + { |
|
323 | + $response = $this->comments->editComment($gistId, $commentId, 'Just editing this comment!'); |
|
324 | + |
|
325 | + $this->assertEquals('Just editing this comment!', $response['body']); |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Test deleting a comment |
|
330 | + * |
|
331 | + * @depends testCreateGist |
|
332 | + * @depends testCreateComment |
|
333 | + * |
|
334 | + * @param string $gistId |
|
335 | + * @param string $commentId |
|
336 | + */ |
|
337 | + public function testDeleteComment(string $gistId, string $commentId) |
|
338 | + { |
|
339 | + $this->assertTrue($this->comments->deleteComment($gistId, $commentId)); |
|
340 | + } |
|
341 | + |
|
342 | + /** |
|
343 | + * Test deleting an existing gist |
|
344 | + * |
|
345 | + * @depends testCreateGist |
|
346 | + * |
|
347 | + * @param string $gistId |
|
348 | + */ |
|
349 | + public function testDeleteGist(string $gistId) |
|
350 | + { |
|
351 | + $this->assertTrue($this->gists->deleteGist($gistId)); |
|
352 | + } |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace FlexyProject\GitHub\Tests\Receiver; |
3 | 3 | |
4 | 4 | use FlexyProject\GitHub\{ |
5 | - Client, Receiver\Miscellaneous, Tests\AbstractClientTest |
|
5 | + Client, Receiver\Miscellaneous, Tests\AbstractClientTest |
|
6 | 6 | }; |
7 | 7 | |
8 | 8 | /** |
@@ -13,209 +13,209 @@ discard block |
||
13 | 13 | class MiscellaneousTest extends AbstractClientTest |
14 | 14 | { |
15 | 15 | |
16 | - /** @var Miscellaneous */ |
|
17 | - protected $miscellaneous; |
|
18 | - |
|
19 | - /** @var Miscellaneous\Emojis */ |
|
20 | - protected $emojis; |
|
21 | - |
|
22 | - /** @var Miscellaneous\Gitignore */ |
|
23 | - protected $gitIgnore; |
|
24 | - |
|
25 | - /** @var Miscellaneous\Licenses */ |
|
26 | - protected $licenses; |
|
27 | - |
|
28 | - /** @var Miscellaneous\Markdown */ |
|
29 | - protected $markdown; |
|
30 | - |
|
31 | - /** @var Miscellaneous\Meta */ |
|
32 | - protected $meta; |
|
33 | - |
|
34 | - /** @var Miscellaneous\RateLimit */ |
|
35 | - protected $rateLimit; |
|
36 | - |
|
37 | - /** |
|
38 | - * MiscellaneousTest constructor. |
|
39 | - * |
|
40 | - * @param null $name |
|
41 | - * @param array $data |
|
42 | - * @param string $dataName |
|
43 | - */ |
|
44 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
45 | - { |
|
46 | - parent::__construct($name, $data, $dataName); |
|
47 | - |
|
48 | - // Miscellaneous |
|
49 | - $this->miscellaneous = $this->client->getReceiver(Client::MISCELLANEOUS); |
|
50 | - |
|
51 | - // Emojis |
|
52 | - $this->emojis = $this->miscellaneous->getReceiver(Miscellaneous::EMOJIS); |
|
53 | - |
|
54 | - // GitIgnore |
|
55 | - $this->gitIgnore = $this->miscellaneous->getReceiver(Miscellaneous::GITIGNORE); |
|
56 | - |
|
57 | - // Licenses |
|
58 | - $this->licenses = $this->miscellaneous->getReceiver(Miscellaneous::LICENSES); |
|
59 | - |
|
60 | - // Markdown |
|
61 | - $this->markdown = $this->miscellaneous->getReceiver(Miscellaneous::MARKDOWN); |
|
62 | - |
|
63 | - // Meta |
|
64 | - $this->meta = $this->miscellaneous->getReceiver(Miscellaneous::META); |
|
65 | - |
|
66 | - // RateLimit |
|
67 | - $this->rateLimit = $this->miscellaneous->getReceiver(Miscellaneous::RATE_LIMIT); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Test instance of Miscellaneous's class |
|
72 | - */ |
|
73 | - public function testMiscellaneous() |
|
74 | - { |
|
75 | - $this->assertInstanceOf(Miscellaneous::class, $this->miscellaneous); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Test instance of Emojis's class |
|
80 | - */ |
|
81 | - public function testEmojis() |
|
82 | - { |
|
83 | - $this->assertInstanceOf(Miscellaneous\Emojis::class, $this->emojis); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Test instance of Gitignore's class |
|
88 | - */ |
|
89 | - public function testGitIgnore() |
|
90 | - { |
|
91 | - $this->assertInstanceOf(Miscellaneous\Gitignore::class, $this->gitIgnore); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Test instance of Licenses's class |
|
96 | - */ |
|
97 | - public function testLicenses() |
|
98 | - { |
|
99 | - $this->assertInstanceOf(Miscellaneous\Licenses::class, $this->licenses); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Test instance of Markdown's class |
|
104 | - */ |
|
105 | - public function testMarkdown() |
|
106 | - { |
|
107 | - $this->assertInstanceOf(Miscellaneous\Markdown::class, $this->markdown); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Test instance of Meta's class |
|
112 | - */ |
|
113 | - public function testMeta() |
|
114 | - { |
|
115 | - $this->assertInstanceOf(Miscellaneous\Meta::class, $this->meta); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Test instance of 's class |
|
120 | - */ |
|
121 | - public function testRateLimit() |
|
122 | - { |
|
123 | - $this->assertInstanceOf(Miscellaneous\RateLimit::class, $this->rateLimit); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Test list available Emojis |
|
128 | - */ |
|
129 | - public function testGetListEmojis() |
|
130 | - { |
|
131 | - $this->assertCount(1508, $this->emojis->get()); |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Test listing available templates |
|
136 | - */ |
|
137 | - public function testListingAvailableTemplates() |
|
138 | - { |
|
139 | - $templates = $this->gitIgnore->listingAvailableTemplates(); |
|
140 | - |
|
141 | - $this->assertContains('Android', $templates); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Test getting a single template |
|
146 | - */ |
|
147 | - public function testGetSingleTemplate() |
|
148 | - { |
|
149 | - $template = $this->gitIgnore->getSingleTemplate('Android'); |
|
150 | - |
|
151 | - $this->assertArrayHasKey('name', $template); |
|
152 | - $this->assertArrayHasKey('source', $template); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Test listing all licenses |
|
157 | - */ |
|
158 | - public function testListAllLicenses() |
|
159 | - { |
|
160 | - $licenses = $this->licenses->listAllLicenses(); |
|
161 | - $license = array_pop($licenses); |
|
162 | - |
|
163 | - $this->assertArrayHasKey('key', $license); |
|
164 | - $this->assertArrayHasKey('name', $license); |
|
165 | - $this->assertArrayHasKey('spdx_id', $license); |
|
166 | - $this->assertArrayHasKey('url', $license); |
|
167 | - $this->assertArrayHasKey('featured', $license); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Test getting individual license |
|
172 | - */ |
|
173 | - public function testGettingIndividualLicense() |
|
174 | - { |
|
175 | - $license = $this->licenses->getIndividualLicense('mit'); |
|
176 | - |
|
177 | - $this->assertArrayHasKey('body', $license); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Test render markdown text |
|
182 | - */ |
|
183 | - public function testRender() |
|
184 | - { |
|
185 | - $output = $this->markdown->render('Hello world FlexyProject/GitHubAPI#43 **cool**, and #43!'); |
|
186 | - |
|
187 | - $this->assertEquals('<p>Hello world FlexyProject/GitHubAPI#43 <strong>cool</strong>, and #43!</p>', |
|
188 | - str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Test render markdown raw text |
|
193 | - */ |
|
194 | - public function testRenderRaw() |
|
195 | - { |
|
196 | - $output = $this->markdown->renderRaw('**cool**'); |
|
197 | - |
|
198 | - $this->assertEquals('<p>{"file":"<strong>cool</strong>"}</p>', |
|
199 | - str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Test getting meta about GitHub.com |
|
204 | - */ |
|
205 | - public function testGetMeta() |
|
206 | - { |
|
207 | - $meta = $this->meta->get(); |
|
208 | - |
|
209 | - $this->assertTrue($meta['verifiable_password_authentication']); |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Test rate limit |
|
214 | - */ |
|
215 | - public function testRate() |
|
216 | - { |
|
217 | - $rateLimit = $this->rateLimit->get(); |
|
218 | - |
|
219 | - $this->assertArrayHasKey('rate', $rateLimit); |
|
220 | - } |
|
16 | + /** @var Miscellaneous */ |
|
17 | + protected $miscellaneous; |
|
18 | + |
|
19 | + /** @var Miscellaneous\Emojis */ |
|
20 | + protected $emojis; |
|
21 | + |
|
22 | + /** @var Miscellaneous\Gitignore */ |
|
23 | + protected $gitIgnore; |
|
24 | + |
|
25 | + /** @var Miscellaneous\Licenses */ |
|
26 | + protected $licenses; |
|
27 | + |
|
28 | + /** @var Miscellaneous\Markdown */ |
|
29 | + protected $markdown; |
|
30 | + |
|
31 | + /** @var Miscellaneous\Meta */ |
|
32 | + protected $meta; |
|
33 | + |
|
34 | + /** @var Miscellaneous\RateLimit */ |
|
35 | + protected $rateLimit; |
|
36 | + |
|
37 | + /** |
|
38 | + * MiscellaneousTest constructor. |
|
39 | + * |
|
40 | + * @param null $name |
|
41 | + * @param array $data |
|
42 | + * @param string $dataName |
|
43 | + */ |
|
44 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
45 | + { |
|
46 | + parent::__construct($name, $data, $dataName); |
|
47 | + |
|
48 | + // Miscellaneous |
|
49 | + $this->miscellaneous = $this->client->getReceiver(Client::MISCELLANEOUS); |
|
50 | + |
|
51 | + // Emojis |
|
52 | + $this->emojis = $this->miscellaneous->getReceiver(Miscellaneous::EMOJIS); |
|
53 | + |
|
54 | + // GitIgnore |
|
55 | + $this->gitIgnore = $this->miscellaneous->getReceiver(Miscellaneous::GITIGNORE); |
|
56 | + |
|
57 | + // Licenses |
|
58 | + $this->licenses = $this->miscellaneous->getReceiver(Miscellaneous::LICENSES); |
|
59 | + |
|
60 | + // Markdown |
|
61 | + $this->markdown = $this->miscellaneous->getReceiver(Miscellaneous::MARKDOWN); |
|
62 | + |
|
63 | + // Meta |
|
64 | + $this->meta = $this->miscellaneous->getReceiver(Miscellaneous::META); |
|
65 | + |
|
66 | + // RateLimit |
|
67 | + $this->rateLimit = $this->miscellaneous->getReceiver(Miscellaneous::RATE_LIMIT); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Test instance of Miscellaneous's class |
|
72 | + */ |
|
73 | + public function testMiscellaneous() |
|
74 | + { |
|
75 | + $this->assertInstanceOf(Miscellaneous::class, $this->miscellaneous); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Test instance of Emojis's class |
|
80 | + */ |
|
81 | + public function testEmojis() |
|
82 | + { |
|
83 | + $this->assertInstanceOf(Miscellaneous\Emojis::class, $this->emojis); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Test instance of Gitignore's class |
|
88 | + */ |
|
89 | + public function testGitIgnore() |
|
90 | + { |
|
91 | + $this->assertInstanceOf(Miscellaneous\Gitignore::class, $this->gitIgnore); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Test instance of Licenses's class |
|
96 | + */ |
|
97 | + public function testLicenses() |
|
98 | + { |
|
99 | + $this->assertInstanceOf(Miscellaneous\Licenses::class, $this->licenses); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Test instance of Markdown's class |
|
104 | + */ |
|
105 | + public function testMarkdown() |
|
106 | + { |
|
107 | + $this->assertInstanceOf(Miscellaneous\Markdown::class, $this->markdown); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Test instance of Meta's class |
|
112 | + */ |
|
113 | + public function testMeta() |
|
114 | + { |
|
115 | + $this->assertInstanceOf(Miscellaneous\Meta::class, $this->meta); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Test instance of 's class |
|
120 | + */ |
|
121 | + public function testRateLimit() |
|
122 | + { |
|
123 | + $this->assertInstanceOf(Miscellaneous\RateLimit::class, $this->rateLimit); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Test list available Emojis |
|
128 | + */ |
|
129 | + public function testGetListEmojis() |
|
130 | + { |
|
131 | + $this->assertCount(1508, $this->emojis->get()); |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Test listing available templates |
|
136 | + */ |
|
137 | + public function testListingAvailableTemplates() |
|
138 | + { |
|
139 | + $templates = $this->gitIgnore->listingAvailableTemplates(); |
|
140 | + |
|
141 | + $this->assertContains('Android', $templates); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Test getting a single template |
|
146 | + */ |
|
147 | + public function testGetSingleTemplate() |
|
148 | + { |
|
149 | + $template = $this->gitIgnore->getSingleTemplate('Android'); |
|
150 | + |
|
151 | + $this->assertArrayHasKey('name', $template); |
|
152 | + $this->assertArrayHasKey('source', $template); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Test listing all licenses |
|
157 | + */ |
|
158 | + public function testListAllLicenses() |
|
159 | + { |
|
160 | + $licenses = $this->licenses->listAllLicenses(); |
|
161 | + $license = array_pop($licenses); |
|
162 | + |
|
163 | + $this->assertArrayHasKey('key', $license); |
|
164 | + $this->assertArrayHasKey('name', $license); |
|
165 | + $this->assertArrayHasKey('spdx_id', $license); |
|
166 | + $this->assertArrayHasKey('url', $license); |
|
167 | + $this->assertArrayHasKey('featured', $license); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Test getting individual license |
|
172 | + */ |
|
173 | + public function testGettingIndividualLicense() |
|
174 | + { |
|
175 | + $license = $this->licenses->getIndividualLicense('mit'); |
|
176 | + |
|
177 | + $this->assertArrayHasKey('body', $license); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Test render markdown text |
|
182 | + */ |
|
183 | + public function testRender() |
|
184 | + { |
|
185 | + $output = $this->markdown->render('Hello world FlexyProject/GitHubAPI#43 **cool**, and #43!'); |
|
186 | + |
|
187 | + $this->assertEquals('<p>Hello world FlexyProject/GitHubAPI#43 <strong>cool</strong>, and #43!</p>', |
|
188 | + str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Test render markdown raw text |
|
193 | + */ |
|
194 | + public function testRenderRaw() |
|
195 | + { |
|
196 | + $output = $this->markdown->renderRaw('**cool**'); |
|
197 | + |
|
198 | + $this->assertEquals('<p>{"file":"<strong>cool</strong>"}</p>', |
|
199 | + str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Test getting meta about GitHub.com |
|
204 | + */ |
|
205 | + public function testGetMeta() |
|
206 | + { |
|
207 | + $meta = $this->meta->get(); |
|
208 | + |
|
209 | + $this->assertTrue($meta['verifiable_password_authentication']); |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Test rate limit |
|
214 | + */ |
|
215 | + public function testRate() |
|
216 | + { |
|
217 | + $rateLimit = $this->rateLimit->get(); |
|
218 | + |
|
219 | + $this->assertArrayHasKey('rate', $rateLimit); |
|
220 | + } |
|
221 | 221 | } |
222 | 222 | \ No newline at end of file |
@@ -11,24 +11,24 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class AbstractClientTest extends TestCase |
13 | 13 | { |
14 | - /** @var Client */ |
|
15 | - protected $client; |
|
14 | + /** @var Client */ |
|
15 | + protected $client; |
|
16 | 16 | |
17 | - /** |
|
18 | - * AbstractTest constructor. |
|
19 | - * |
|
20 | - * @param null $name |
|
21 | - * @param array $data |
|
22 | - * @param string $dataName |
|
23 | - */ |
|
24 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
25 | - { |
|
26 | - // Create a client object |
|
27 | - $this->client = new Client(); |
|
17 | + /** |
|
18 | + * AbstractTest constructor. |
|
19 | + * |
|
20 | + * @param null $name |
|
21 | + * @param array $data |
|
22 | + * @param string $dataName |
|
23 | + */ |
|
24 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
25 | + { |
|
26 | + // Create a client object |
|
27 | + $this->client = new Client(); |
|
28 | 28 | |
29 | - // Set auth credentials |
|
30 | - $this->client->setHttpAuth($GLOBALS['USERNAME'], $GLOBALS['PASSWORD']); |
|
29 | + // Set auth credentials |
|
30 | + $this->client->setHttpAuth($GLOBALS['USERNAME'], $GLOBALS['PASSWORD']); |
|
31 | 31 | |
32 | - parent::__construct($name, $data, $dataName); |
|
33 | - } |
|
32 | + parent::__construct($name, $data, $dataName); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | use FlexyProject\GitHub\Client; |
5 | 5 | use FlexyProject\GitHub\Receiver\{ |
6 | - Activity, Enterprise, Gists, GitData, Issues, Miscellaneous, Organizations, PullRequests, Repositories, Search, Users |
|
6 | + Activity, Enterprise, Gists, GitData, Issues, Miscellaneous, Organizations, PullRequests, Repositories, Search, Users |
|
7 | 7 | }; |
8 | 8 | |
9 | 9 | /** |
@@ -14,99 +14,99 @@ discard block |
||
14 | 14 | class ClientTest extends AbstractClientTest |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Test instance of Client's class |
|
19 | - */ |
|
20 | - public function testClient() |
|
21 | - { |
|
22 | - $this->assertInstanceOf(Client::class, $this->client); |
|
23 | - } |
|
17 | + /** |
|
18 | + * Test instance of Client's class |
|
19 | + */ |
|
20 | + public function testClient() |
|
21 | + { |
|
22 | + $this->assertInstanceOf(Client::class, $this->client); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Test instance of Activity's class |
|
27 | - */ |
|
28 | - public function testActivityReceiver() |
|
29 | - { |
|
30 | - $this->assertInstanceOf(Activity::class, $this->client->getReceiver(Client::ACTIVITY)); |
|
31 | - } |
|
25 | + /** |
|
26 | + * Test instance of Activity's class |
|
27 | + */ |
|
28 | + public function testActivityReceiver() |
|
29 | + { |
|
30 | + $this->assertInstanceOf(Activity::class, $this->client->getReceiver(Client::ACTIVITY)); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Test instance of Enterprise's class |
|
35 | - */ |
|
36 | - public function testEnterpriseReceiver() |
|
37 | - { |
|
38 | - $this->assertInstanceOf(Enterprise::class, $this->client->getReceiver(Client::ENTERPRISE)); |
|
39 | - } |
|
33 | + /** |
|
34 | + * Test instance of Enterprise's class |
|
35 | + */ |
|
36 | + public function testEnterpriseReceiver() |
|
37 | + { |
|
38 | + $this->assertInstanceOf(Enterprise::class, $this->client->getReceiver(Client::ENTERPRISE)); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Test instance of Gists's class |
|
43 | - */ |
|
44 | - public function testGistsReceiver() |
|
45 | - { |
|
46 | - $this->assertInstanceOf(Gists::class, $this->client->getReceiver(Client::GISTS)); |
|
47 | - } |
|
41 | + /** |
|
42 | + * Test instance of Gists's class |
|
43 | + */ |
|
44 | + public function testGistsReceiver() |
|
45 | + { |
|
46 | + $this->assertInstanceOf(Gists::class, $this->client->getReceiver(Client::GISTS)); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Test instance of GitData's class |
|
51 | - */ |
|
52 | - public function testGitDataReceiver() |
|
53 | - { |
|
54 | - $this->assertInstanceOf(GitData::class, $this->client->getReceiver(Client::GIT_DATA)); |
|
55 | - } |
|
49 | + /** |
|
50 | + * Test instance of GitData's class |
|
51 | + */ |
|
52 | + public function testGitDataReceiver() |
|
53 | + { |
|
54 | + $this->assertInstanceOf(GitData::class, $this->client->getReceiver(Client::GIT_DATA)); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Test instance of Issues's class |
|
59 | - */ |
|
60 | - public function testIssuesReceiver() |
|
61 | - { |
|
62 | - $this->assertInstanceOf(Issues::class, $this->client->getReceiver(Client::ISSUES)); |
|
63 | - } |
|
57 | + /** |
|
58 | + * Test instance of Issues's class |
|
59 | + */ |
|
60 | + public function testIssuesReceiver() |
|
61 | + { |
|
62 | + $this->assertInstanceOf(Issues::class, $this->client->getReceiver(Client::ISSUES)); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Test instance of Miscellaneous's class |
|
67 | - */ |
|
68 | - public function testMiscellaneousReceiver() |
|
69 | - { |
|
70 | - $this->assertInstanceOf(Miscellaneous::class, $this->client->getReceiver(Client::MISCELLANEOUS)); |
|
71 | - } |
|
65 | + /** |
|
66 | + * Test instance of Miscellaneous's class |
|
67 | + */ |
|
68 | + public function testMiscellaneousReceiver() |
|
69 | + { |
|
70 | + $this->assertInstanceOf(Miscellaneous::class, $this->client->getReceiver(Client::MISCELLANEOUS)); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Test instance of Organizations's class |
|
75 | - */ |
|
76 | - public function testOrganizationsReceiver() |
|
77 | - { |
|
78 | - $this->assertInstanceOf(Organizations::class, $this->client->getReceiver(Client::ORGANIZATIONS)); |
|
79 | - } |
|
73 | + /** |
|
74 | + * Test instance of Organizations's class |
|
75 | + */ |
|
76 | + public function testOrganizationsReceiver() |
|
77 | + { |
|
78 | + $this->assertInstanceOf(Organizations::class, $this->client->getReceiver(Client::ORGANIZATIONS)); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Test instance of PullRequests's class |
|
83 | - */ |
|
84 | - public function testPullRequestsReceiver() |
|
85 | - { |
|
86 | - $this->assertInstanceOf(PullRequests::class, $this->client->getReceiver(Client::PULL_REQUESTS)); |
|
87 | - } |
|
81 | + /** |
|
82 | + * Test instance of PullRequests's class |
|
83 | + */ |
|
84 | + public function testPullRequestsReceiver() |
|
85 | + { |
|
86 | + $this->assertInstanceOf(PullRequests::class, $this->client->getReceiver(Client::PULL_REQUESTS)); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Test instance of Repositories's class |
|
91 | - */ |
|
92 | - public function testRepositoriesReceiver() |
|
93 | - { |
|
94 | - $this->assertInstanceOf(Repositories::class, $this->client->getReceiver(Client::REPOSITORIES)); |
|
95 | - } |
|
89 | + /** |
|
90 | + * Test instance of Repositories's class |
|
91 | + */ |
|
92 | + public function testRepositoriesReceiver() |
|
93 | + { |
|
94 | + $this->assertInstanceOf(Repositories::class, $this->client->getReceiver(Client::REPOSITORIES)); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Test instance of Search's class |
|
99 | - */ |
|
100 | - public function testSearchReceiver() |
|
101 | - { |
|
102 | - $this->assertInstanceOf(Search::class, $this->client->getReceiver(Client::SEARCH)); |
|
103 | - } |
|
97 | + /** |
|
98 | + * Test instance of Search's class |
|
99 | + */ |
|
100 | + public function testSearchReceiver() |
|
101 | + { |
|
102 | + $this->assertInstanceOf(Search::class, $this->client->getReceiver(Client::SEARCH)); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Test instance of Users's class |
|
107 | - */ |
|
108 | - public function testUsersReceiver() |
|
109 | - { |
|
110 | - $this->assertInstanceOf(Users::class, $this->client->getReceiver(Client::USERS)); |
|
111 | - } |
|
105 | + /** |
|
106 | + * Test instance of Users's class |
|
107 | + */ |
|
108 | + public function testUsersReceiver() |
|
109 | + { |
|
110 | + $this->assertInstanceOf(Users::class, $this->client->getReceiver(Client::USERS)); |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | \ No newline at end of file |
@@ -12,27 +12,27 @@ |
||
12 | 12 | */ |
13 | 13 | class AbstractWebHookTest extends TestCase |
14 | 14 | { |
15 | - /** @var WebHook */ |
|
16 | - protected $webHook; |
|
15 | + /** @var WebHook */ |
|
16 | + protected $webHook; |
|
17 | 17 | |
18 | - /** @var Payload */ |
|
19 | - protected $payload; |
|
18 | + /** @var Payload */ |
|
19 | + protected $payload; |
|
20 | 20 | |
21 | - /** |
|
22 | - * WebHookTest constructor. |
|
23 | - * |
|
24 | - * @param null $name |
|
25 | - * @param array $data |
|
26 | - * @param string $dataName |
|
27 | - */ |
|
28 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
29 | - { |
|
30 | - // Create a WebHook object |
|
31 | - $this->webHook = new WebHook(); |
|
21 | + /** |
|
22 | + * WebHookTest constructor. |
|
23 | + * |
|
24 | + * @param null $name |
|
25 | + * @param array $data |
|
26 | + * @param string $dataName |
|
27 | + */ |
|
28 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
29 | + { |
|
30 | + // Create a WebHook object |
|
31 | + $this->webHook = new WebHook(); |
|
32 | 32 | |
33 | - // Create a Payload object |
|
34 | - $this->payload = $this->webHook->getEvent(WebHook::PAYLOAD); |
|
33 | + // Create a Payload object |
|
34 | + $this->payload = $this->webHook->getEvent(WebHook::PAYLOAD); |
|
35 | 35 | |
36 | - parent::__construct($name, $data, $dataName); |
|
37 | - } |
|
36 | + parent::__construct($name, $data, $dataName); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -10,14 +10,14 @@ |
||
10 | 10 | */ |
11 | 11 | class PayloadTest extends AbstractWebHookTest |
12 | 12 | { |
13 | - /** |
|
14 | - * Test setting a secret |
|
15 | - */ |
|
16 | - public function testSecret() |
|
17 | - { |
|
18 | - $this->payload->setSecret('your-secret'); |
|
13 | + /** |
|
14 | + * Test setting a secret |
|
15 | + */ |
|
16 | + public function testSecret() |
|
17 | + { |
|
18 | + $this->payload->setSecret('your-secret'); |
|
19 | 19 | |
20 | - $this->assertEquals(hash_hmac('sha1', $this->payload->getRawData(), 'your-secret'), |
|
21 | - $this->payload->getSecret()); |
|
22 | - } |
|
20 | + $this->assertEquals(hash_hmac('sha1', $this->payload->getRawData(), 'your-secret'), |
|
21 | + $this->payload->getSecret()); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -11,137 +11,137 @@ |
||
11 | 11 | class Events extends AbstractActivity |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * List public events |
|
16 | - * |
|
17 | - * @link https://developer.github.com/v3/activity/events/#list-public-events |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public function listPublicEvents(): array |
|
21 | - { |
|
22 | - return $this->getApi()->request('/events'); |
|
23 | - } |
|
14 | + /** |
|
15 | + * List public events |
|
16 | + * |
|
17 | + * @link https://developer.github.com/v3/activity/events/#list-public-events |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public function listPublicEvents(): array |
|
21 | + { |
|
22 | + return $this->getApi()->request('/events'); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * List repository events |
|
27 | - * |
|
28 | - * @link https://developer.github.com/v3/activity/events/#list-repository-events |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - public function listRepositoryEvents(): array |
|
32 | - { |
|
33 | - return $this->getApi()->request($this->getApi() |
|
34 | - ->sprintf('/repos/:owner/:repo/events', $this->getActivity()->getOwner(), |
|
35 | - $this->getActivity()->getRepo())); |
|
36 | - } |
|
25 | + /** |
|
26 | + * List repository events |
|
27 | + * |
|
28 | + * @link https://developer.github.com/v3/activity/events/#list-repository-events |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + public function listRepositoryEvents(): array |
|
32 | + { |
|
33 | + return $this->getApi()->request($this->getApi() |
|
34 | + ->sprintf('/repos/:owner/:repo/events', $this->getActivity()->getOwner(), |
|
35 | + $this->getActivity()->getRepo())); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * List issue events for a repository |
|
40 | - * |
|
41 | - * @link https://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository |
|
42 | - * @return array |
|
43 | - */ |
|
44 | - public function listIssueEvents(): array |
|
45 | - { |
|
46 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/events', |
|
47 | - $this->getActivity()->getOwner(), $this->getActivity()->getRepo())); |
|
48 | - } |
|
38 | + /** |
|
39 | + * List issue events for a repository |
|
40 | + * |
|
41 | + * @link https://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository |
|
42 | + * @return array |
|
43 | + */ |
|
44 | + public function listIssueEvents(): array |
|
45 | + { |
|
46 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/events', |
|
47 | + $this->getActivity()->getOwner(), $this->getActivity()->getRepo())); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * List public events for a network of repositories |
|
52 | - * |
|
53 | - * @link https://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories |
|
54 | - * @return array |
|
55 | - */ |
|
56 | - public function listPublicNetworkEvents(): array |
|
57 | - { |
|
58 | - return $this->getApi()->request($this->getApi()->sprintf('/networks/:owner/:repo/events', |
|
59 | - $this->getActivity()->getOwner(), $this->getActivity()->getRepo())); |
|
60 | - } |
|
50 | + /** |
|
51 | + * List public events for a network of repositories |
|
52 | + * |
|
53 | + * @link https://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories |
|
54 | + * @return array |
|
55 | + */ |
|
56 | + public function listPublicNetworkEvents(): array |
|
57 | + { |
|
58 | + return $this->getApi()->request($this->getApi()->sprintf('/networks/:owner/:repo/events', |
|
59 | + $this->getActivity()->getOwner(), $this->getActivity()->getRepo())); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * List public events for an organization |
|
64 | - * |
|
65 | - * @link https://developer.github.com/v3/activity/events/#list-public-events-for-an-organization |
|
66 | - * |
|
67 | - * @param string $organization |
|
68 | - * |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function listPublicOrganizationEvents(string $organization): array |
|
72 | - { |
|
73 | - return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/events', $organization)); |
|
74 | - } |
|
62 | + /** |
|
63 | + * List public events for an organization |
|
64 | + * |
|
65 | + * @link https://developer.github.com/v3/activity/events/#list-public-events-for-an-organization |
|
66 | + * |
|
67 | + * @param string $organization |
|
68 | + * |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function listPublicOrganizationEvents(string $organization): array |
|
72 | + { |
|
73 | + return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/events', $organization)); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * List events that a user has received |
|
78 | - * |
|
79 | - * @link https://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received |
|
80 | - * |
|
81 | - * @param string $username |
|
82 | - * |
|
83 | - * @return array |
|
84 | - */ |
|
85 | - public function listUserReceiveEvents(string $username): array |
|
86 | - { |
|
87 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username/received_events', $username)); |
|
88 | - } |
|
76 | + /** |
|
77 | + * List events that a user has received |
|
78 | + * |
|
79 | + * @link https://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received |
|
80 | + * |
|
81 | + * @param string $username |
|
82 | + * |
|
83 | + * @return array |
|
84 | + */ |
|
85 | + public function listUserReceiveEvents(string $username): array |
|
86 | + { |
|
87 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username/received_events', $username)); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * List public events that a user has received |
|
92 | - * |
|
93 | - * @link https://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received |
|
94 | - * |
|
95 | - * @param string $username |
|
96 | - * |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function listPublicUserReceiveEvents(string $username): array |
|
100 | - { |
|
101 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username/received_events/public', $username)); |
|
102 | - } |
|
90 | + /** |
|
91 | + * List public events that a user has received |
|
92 | + * |
|
93 | + * @link https://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received |
|
94 | + * |
|
95 | + * @param string $username |
|
96 | + * |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function listPublicUserReceiveEvents(string $username): array |
|
100 | + { |
|
101 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username/received_events/public', $username)); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * List events performed by a user |
|
106 | - * |
|
107 | - * @link https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user |
|
108 | - * |
|
109 | - * @param string $username |
|
110 | - * |
|
111 | - * @return array |
|
112 | - */ |
|
113 | - public function listUserPerformedEvents(string $username): array |
|
114 | - { |
|
115 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username/events', $username)); |
|
116 | - } |
|
104 | + /** |
|
105 | + * List events performed by a user |
|
106 | + * |
|
107 | + * @link https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user |
|
108 | + * |
|
109 | + * @param string $username |
|
110 | + * |
|
111 | + * @return array |
|
112 | + */ |
|
113 | + public function listUserPerformedEvents(string $username): array |
|
114 | + { |
|
115 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username/events', $username)); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * List public events performed by a user |
|
120 | - * |
|
121 | - * @link https://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user |
|
122 | - * |
|
123 | - * @param string $username |
|
124 | - * |
|
125 | - * @return array |
|
126 | - */ |
|
127 | - public function listPublicUserPerformedEvents(string $username): array |
|
128 | - { |
|
129 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username/events/public', $username)); |
|
130 | - } |
|
118 | + /** |
|
119 | + * List public events performed by a user |
|
120 | + * |
|
121 | + * @link https://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user |
|
122 | + * |
|
123 | + * @param string $username |
|
124 | + * |
|
125 | + * @return array |
|
126 | + */ |
|
127 | + public function listPublicUserPerformedEvents(string $username): array |
|
128 | + { |
|
129 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username/events/public', $username)); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * List events for an organization |
|
134 | - * |
|
135 | - * @link https://developer.github.com/v3/activity/events/#list-events-for-an-organization |
|
136 | - * |
|
137 | - * @param string $username |
|
138 | - * @param string $organization |
|
139 | - * |
|
140 | - * @return array |
|
141 | - */ |
|
142 | - public function listOrganizationEvents(string $username, string $organization): array |
|
143 | - { |
|
144 | - return $this->getApi()->request($this->getApi() |
|
145 | - ->sprintf('/users/:username/events/orgs/:org', $username, $organization)); |
|
146 | - } |
|
132 | + /** |
|
133 | + * List events for an organization |
|
134 | + * |
|
135 | + * @link https://developer.github.com/v3/activity/events/#list-events-for-an-organization |
|
136 | + * |
|
137 | + * @param string $username |
|
138 | + * @param string $organization |
|
139 | + * |
|
140 | + * @return array |
|
141 | + */ |
|
142 | + public function listOrganizationEvents(string $username, string $organization): array |
|
143 | + { |
|
144 | + return $this->getApi()->request($this->getApi() |
|
145 | + ->sprintf('/users/:username/events/orgs/:org', $username, $organization)); |
|
146 | + } |
|
147 | 147 | } |
148 | 148 | \ No newline at end of file |