Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
- API for Repo\Cards
- API for Repo\Columns
- API for Repo\Projects
- API for User\MyRepositories
- Methods in Repo API for frequency and participation

### Changed
Expand Down
24 changes: 19 additions & 5 deletions lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public function subscriptions($username)
}

/**
* Get the repositories of a user.
* List public repositories for the specified user.
*
* @link http://developer.github.com/v3/repos/
* @link https://developer.github.com/v3/repos/#list-user-repositories
*
* @param string $username the username
* @param string $type role in the repository
Expand All @@ -158,11 +158,25 @@ public function subscriptions($username)
*/
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
{
return $this->get('/users/'.rawurlencode($username).'/repos', array(
return $this->get('/users/'.rawurlencode($username).'/repos', [
'type' => $type,
'sort' => $sort,
'direction' => $direction
));
'direction' => $direction,
]);
}

/**
* List repositories that are accessible to the authenticated user.
*
* @link https://developer.github.com/v3/repos/#list-your-repositories
*
* @param array $params visibility, affiliation, type, sort, direction
*
* @return array list of the user repositories
*/
public function myRepositories(array $params = [])
{
return $this->get('/user/repos', $params);
}

/**
Expand Down
15 changes: 15 additions & 0 deletions test/Github/Tests/Api/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ public function shouldGetUserRepositories()
$this->assertEquals($expectedArray, $api->repositories('l3l0'));
}

/**
* @test
*/
public function shouldGetMyRepositories()
{
$expectedArray = [['id' => 1, 'name' => 'l3l0repo']];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')->with('/user/repos', [])
->will($this->returnValue($expectedArray));

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

/**
* @test
*/
Expand Down