Skip to content

Commit d112568

Browse files
committed
add Apps endpoint get /repos/:owner/:repo/installation
1 parent 485e48e commit d112568

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/Github/Api/Apps.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ public function getInstallationForOrganization($org)
7979
return $this->get('/org/'.rawurldecode($org).'/installation');
8080
}
8181

82+
/**
83+
* Get an installation of the application for a repository
84+
*
85+
* @link https://developer.github.com/v3/apps/#get-a-repository-installation
86+
*
87+
* @param $owner the owner of a repository
88+
* @param $repo the name of the repository
89+
* @return array
90+
*/
91+
public function getInstallationForRepo($owner, $repo)
92+
{
93+
return $this->get('/repos/'.rawurldecode($owner).'/'.rawurldecode($repo).'/installation');
94+
}
95+
8296
/**
8397
* Delete an installation of the application
8498
*

test/Github/Tests/Api/AppTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ public function shouldGetInstallationForOrganization()
7272
$this->assertEquals($result, $api->getInstallationForOrganization('1234'));
7373
}
7474

75+
/**
76+
* @test
77+
*/
78+
public function shouldGetInstallationForRepo()
79+
{
80+
$result = ['installation1'];
81+
82+
$api = $this->getApiMock();
83+
$api->expects($this->once())
84+
->method('get')
85+
->with('/repos/MyOrg/MyRepo/installation')
86+
->willReturn($result);
87+
88+
$this->assertEquals($result, $api->getInstallationForRepo('MyOrg', 'MyRepo'));
89+
}
90+
7591
/**
7692
* @test
7793
*/

0 commit comments

Comments
 (0)