Skip to content

Add ability to define parameters for /users/{user}/starred #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Github/Api/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
14 changes: 10 additions & 4 deletions lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
}

Expand Down
18 changes: 18 additions & 0 deletions test/Github/Tests/Api/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function shouldGetUserOrganizations()

$this->assertEquals($expectedArray, $api->organizations('l3l0'));
}

public function shouldGetUserOrgs()
{
$expectedArray = array(array(
Expand All @@ -61,6 +62,7 @@ public function shouldGetUserOrgs()

$this->assertEquals($expectedArray, $api->orgs());
}

/**
* @test
*/
Expand Down Expand Up @@ -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
*/
Expand Down