Skip to content

Commit 984e463

Browse files
committed
Merge pull request #353 from daconex/master
Created method to add user to an organization
2 parents 3664fd8 + 07cb4c1 commit 984e463

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/Github/Api/Organization/Members.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public function conceal($organization, $username)
4646
return $this->delete('orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username));
4747
}
4848

49+
/*
50+
* Add user to organization
51+
*/
52+
public function add($organization, $username)
53+
{
54+
return $this->put('orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username));
55+
}
56+
4957
public function remove($organization, $username)
5058
{
5159
return $this->delete('orgs/'.rawurlencode($organization).'/members/'.rawurlencode($username));

test/Github/Tests/Api/Organization/MembersTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ public function shouldCheckIfOrganizationMember()
5454
$this->assertEquals($expectedValue, $api->check('KnpLabs', 'l3l0'));
5555
}
5656

57+
/**
58+
* @test
59+
*/
60+
public function shouldAddOrganizationMember()
61+
{
62+
$expectedValue = 'response';
63+
64+
$api = $this->getApiMock();
65+
$api->expects($this->once())
66+
->method('put')
67+
->with('orgs/KnpLabs/memberships/l3l0')
68+
->will($this->returnValue($expectedValue));
69+
70+
$this->assertEquals($expectedValue, $api->add('KnpLabs', 'l3l0'));
71+
}
72+
5773
/**
5874
* @test
5975
*/

0 commit comments

Comments
 (0)