diff --git a/doc/repos.md b/doc/repos.md index 8dc996d6434..ca8a8b4da74 100644 --- a/doc/repos.md +++ b/doc/repos.md @@ -249,3 +249,11 @@ use Github\HttpClient\Message\ResponseMediator; $data = $client->getHttpClient()->get('/repositories/24560307'); $repo = ResponseMediator::getContent($data); ``` + +### Get the milestones of a repository + +```php +milestones = $client->api('repo')->milestones('ornicar', 'php-github-api'); +``` + +Returns a list of milestones. diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index fcafd4b2517..34d9dcbb25e 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -463,4 +463,14 @@ public function merge($username, $repository, $base, $head, $message = null) 'commit_message' => $message )); } + + /** + * @param string $username + * @param string $repository + * @return array + */ + public function milestones($username, $repository) + { + return $this->get('repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/milestones'); + } } diff --git a/test/Github/Tests/Api/RepoTest.php b/test/Github/Tests/Api/RepoTest.php index d14df11e650..200b9cbf447 100644 --- a/test/Github/Tests/Api/RepoTest.php +++ b/test/Github/Tests/Api/RepoTest.php @@ -188,6 +188,22 @@ public function shouldGetRepositoryLanguages() $this->assertEquals($expectedArray, $api->languages('KnpLabs', 'php-github-api')); } + /** + * @test + */ + public function shouldGetRepositoryMilestones() + { + $expectedArray = array('milestone1', 'milestone2'); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('repos/KnpLabs/php-github-api/milestones') + ->will($this->returnValue($expectedArray)); + + $this->assertEquals($expectedArray, $api->milestones('KnpLabs', 'php-github-api')); + } + /** * @test */