Skip to content

Commit 4033c2b

Browse files
committed
add Apps endpoint get /users/:username/installation
1 parent d112568 commit 4033c2b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/Github/Api/Apps.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ public function getInstallationForRepo($owner, $repo)
9393
return $this->get('/repos/'.rawurldecode($owner).'/'.rawurldecode($repo).'/installation');
9494
}
9595

96+
/**
97+
* Get an installation of the application for a user
98+
*
99+
* @link https://developer.github.com/v3/apps/#get-a-user-installation
100+
*
101+
* @param $username
102+
* @return array
103+
*/
104+
public function getInstallationForUser($username)
105+
{
106+
return $this->get('/users/'.rawurldecode($username).'/installation');
107+
}
108+
96109
/**
97110
* Delete an installation of the application
98111
*

test/Github/Tests/Api/AppTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ public function shouldGetInstallationForRepo()
8888
$this->assertEquals($result, $api->getInstallationForRepo('MyOrg', 'MyRepo'));
8989
}
9090

91+
/**
92+
* @test
93+
*/
94+
public function shouldGetInstallationForUser()
95+
{
96+
$result = ['installation1'];
97+
98+
$api = $this->getApiMock();
99+
$api->expects($this->once())
100+
->method('get')
101+
->with('/users/octocat/installation')
102+
->willReturn($result);
103+
104+
$this->assertEquals($result, $api->getInstallationForUser('octocat'));
105+
}
106+
91107
/**
92108
* @test
93109
*/

0 commit comments

Comments
 (0)