diff --git a/lib/Github/Api/Organization/Members.php b/lib/Github/Api/Organization/Members.php index 7358ed27689..b1c0563c590 100644 --- a/lib/Github/Api/Organization/Members.php +++ b/lib/Github/Api/Organization/Members.php @@ -46,6 +46,14 @@ public function conceal($organization, $username) return $this->delete('orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username)); } + /* + * Add user to organization + */ + public function add($organization, $username) + { + return $this->put('orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username)); + } + public function remove($organization, $username) { return $this->delete('orgs/'.rawurlencode($organization).'/members/'.rawurlencode($username)); diff --git a/test/Github/Tests/Api/Organization/MembersTest.php b/test/Github/Tests/Api/Organization/MembersTest.php index 7111766b82e..8a6a252e0c8 100644 --- a/test/Github/Tests/Api/Organization/MembersTest.php +++ b/test/Github/Tests/Api/Organization/MembersTest.php @@ -54,6 +54,22 @@ public function shouldCheckIfOrganizationMember() $this->assertEquals($expectedValue, $api->check('KnpLabs', 'l3l0')); } + /** + * @test + */ + public function shouldAddOrganizationMember() + { + $expectedValue = 'response'; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with('orgs/KnpLabs/memberships/l3l0') + ->will($this->returnValue($expectedValue)); + + $this->assertEquals($expectedValue, $api->add('KnpLabs', 'l3l0')); + } + /** * @test */