Skip to content

Add a function to get user organizations #505

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 4 commits into from
Jan 17, 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
11 changes: 11 additions & 0 deletions lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ public function organizations($username)
return $this->get('/users/'.rawurlencode($username).'/orgs');
}

/**
* Get user organizations
*
* @link https://developer.github.com/v3/orgs/#list-your-organizations
*
* @return array information about organizations that authenticated user belongs to
*/
public function orgs()
{
return $this->get('/user/orgs');
}
/**
* Request the users that a specific user is following.
*
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,7 +42,25 @@ public function shouldGetUserOrganizations()

$this->assertEquals($expectedArray, $api->organizations('l3l0'));
}
public function shouldGetUserOrgs()
{
$expectedArray = array(array(
'id' => 202732,
'url' => 'https://api.github.com/orgs/KnpLabs',
'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos',
'events_url' => 'https://api.github.com/orgs/KnpLabs/events',
'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}',
'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}'
));

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

$this->assertEquals($expectedArray, $api->orgs());
}
/**
* @test
*/
Expand Down