diff --git a/lib/Github/Api/CurrentUser.php b/lib/Github/Api/CurrentUser.php index dc2a877d7e3..742f5579774 100644 --- a/lib/Github/Api/CurrentUser.php +++ b/lib/Github/Api/CurrentUser.php @@ -112,7 +112,7 @@ public function teams() * * @param string $type role in the repository * @param string $sort sort by - * @param string $direction direction of sort, ask or desc + * @param string $direction direction of sort, asc or desc * * @return array */ diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 65702296f5e..c11716040d8 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -129,15 +129,21 @@ public function watched($username) * * @link http://developer.github.com/v3/activity/starring/ * - * @param string $username the username - * @param int $page the page number of the paginated result set + * @param string $username the username + * @param int $page the page number of the paginated result set + * @param int $perPage the number of results per page + * @param string $sort sort by (possible values: created, updated) + * @param string $direction direction of sort (possible values: asc, desc) * * @return array list of starred repositories */ - public function starred($username, $page = 1) + public function starred($username, $page = 1, $perPage = 30, $sort = 'created', $direction = 'desc') { return $this->get('/users/'.rawurlencode($username).'/starred', array( - 'page' => $page + 'page' => $page, + 'per_page' => $perPage, + 'sort' => $sort, + 'direction' => $direction, )); } diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index 19f2e380e29..8e505cfd862 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -42,6 +42,7 @@ public function shouldGetUserOrganizations() $this->assertEquals($expectedArray, $api->organizations('l3l0')); } + public function shouldGetUserOrgs() { $expectedArray = array(array( @@ -61,6 +62,7 @@ public function shouldGetUserOrgs() $this->assertEquals($expectedArray, $api->orgs()); } + /** * @test */ @@ -131,6 +133,22 @@ public function shouldGetUserFollowers() $this->assertEquals($expectedArray, $api->followers('l3l0')); } + /** + * @test + */ + public function shouldGetStarredToRepositories() + { + $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('/users/l3l0/starred', ['page' => 2, 'per_page' => 30, 'sort' => 'created', 'direction' => 'desc']) + ->will($this->returnValue($expectedArray)); + + $this->assertEquals($expectedArray, $api->starred('l3l0', 2)); + } + /** * @test */