Skip to content

Commit 1fb2b45

Browse files
committed
Merge pull request #274 from Expensify/master
Add 'get milestones' for repo api
2 parents 1c08236 + 5b234d1 commit 1fb2b45

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

doc/repos.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,11 @@ use Github\HttpClient\Message\ResponseMediator;
249249
$data = $client->getHttpClient()->get('/repositories/24560307');
250250
$repo = ResponseMediator::getContent($data);
251251
```
252+
253+
### Get the milestones of a repository
254+
255+
```php
256+
milestones = $client->api('repo')->milestones('ornicar', 'php-github-api');
257+
```
258+
259+
Returns a list of milestones.

lib/Github/Api/Repo.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,14 @@ public function merge($username, $repository, $base, $head, $message = null)
463463
'commit_message' => $message
464464
));
465465
}
466+
467+
/**
468+
* @param string $username
469+
* @param string $repository
470+
* @return array
471+
*/
472+
public function milestones($username, $repository)
473+
{
474+
return $this->get('repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/milestones');
475+
}
466476
}

test/Github/Tests/Api/RepoTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ public function shouldGetRepositoryLanguages()
188188
$this->assertEquals($expectedArray, $api->languages('KnpLabs', 'php-github-api'));
189189
}
190190

191+
/**
192+
* @test
193+
*/
194+
public function shouldGetRepositoryMilestones()
195+
{
196+
$expectedArray = array('milestone1', 'milestone2');
197+
198+
$api = $this->getApiMock();
199+
$api->expects($this->once())
200+
->method('get')
201+
->with('repos/KnpLabs/php-github-api/milestones')
202+
->will($this->returnValue($expectedArray));
203+
204+
$this->assertEquals($expectedArray, $api->milestones('KnpLabs', 'php-github-api'));
205+
}
206+
191207
/**
192208
* @test
193209
*/

0 commit comments

Comments
 (0)