Skip to content

Commit 4a06d34

Browse files
authored
Merge pull request #505 from m1guelpf/patch-1
Add a function to get user organizations
2 parents 2d499a2 + 4919340 commit 4a06d34

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/Github/Api/User.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ public function organizations($username)
7171
return $this->get('/users/'.rawurlencode($username).'/orgs');
7272
}
7373

74+
/**
75+
* Get user organizations
76+
*
77+
* @link https://developer.github.com/v3/orgs/#list-your-organizations
78+
*
79+
* @return array information about organizations that authenticated user belongs to
80+
*/
81+
public function orgs()
82+
{
83+
return $this->get('/user/orgs');
84+
}
7485
/**
7586
* Request the users that a specific user is following.
7687
*

test/Github/Tests/Api/UserTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,25 @@ public function shouldGetUserOrganizations()
4242

4343
$this->assertEquals($expectedArray, $api->organizations('l3l0'));
4444
}
45+
public function shouldGetUserOrgs()
46+
{
47+
$expectedArray = array(array(
48+
'id' => 202732,
49+
'url' => 'https://api.github.com/orgs/KnpLabs',
50+
'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos',
51+
'events_url' => 'https://api.github.com/orgs/KnpLabs/events',
52+
'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}',
53+
'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}'
54+
));
4555

56+
$api = $this->getApiMock();
57+
$api->expects($this->once())
58+
->method('get')
59+
->with('/user/orgs')
60+
->will($this->returnValue($expectedArray));
61+
62+
$this->assertEquals($expectedArray, $api->orgs());
63+
}
4664
/**
4765
* @test
4866
*/

0 commit comments

Comments
 (0)