From 15d0116010494ba3868d3c33ffbd92b22a57339d Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Tue, 28 Aug 2018 09:19:27 -0400 Subject: [PATCH] Adjust: installationn access token endpoint --- lib/Github/Api/Apps.php | 4 +++- test/Github/Tests/Api/AppTest.php | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index 8ef0833875e..1467d2aaf43 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -16,6 +16,8 @@ class Apps extends AbstractApi * @param int $userId An optional user id on behalf of whom the * token will be requested * + * @link https://developer.github.com/v3/apps/#create-a-new-installation-token + * * @return array token and token metadata */ public function createInstallationToken($installationId, $userId = null) @@ -25,7 +27,7 @@ public function createInstallationToken($installationId, $userId = null) $parameters['user_id'] = $userId; } - return $this->post('/installations/'.rawurlencode($installationId).'/access_tokens', $parameters); + return $this->post('/app/installations/'.rawurlencode($installationId).'/access_tokens', $parameters); } /** diff --git a/test/Github/Tests/Api/AppTest.php b/test/Github/Tests/Api/AppTest.php index 75e028dbfcf..446ebf5d72f 100644 --- a/test/Github/Tests/Api/AppTest.php +++ b/test/Github/Tests/Api/AppTest.php @@ -4,6 +4,26 @@ class AppTest extends TestCase { + /** + * @test + */ + public function shouldCreateInstallationTokenForInstallation() + { + $result = [ + 'token' => 'v1.1f699f1069f60xxx', + 'expires_at' => '2016-07-11T22:14:10Z', + ]; + $installationId = 'installation1'; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with('/app/installations/'.$installationId.'/access_tokens', []) + ->willReturn($result); + + $this->assertEquals($result, $api->createInstallationToken($installationId)); + } + /** * @test */