Skip to content

Commit 83ec71f

Browse files
niekbrNiek Brekelmans
andauthored
[11.9] Add support for Projects::projectAccessToken (#715)
Co-authored-by: Niek Brekelmans <[email protected]>
1 parent e1f74cc commit 83ec71f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Api/Projects.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,17 @@ public function projectAccessTokens($project_id)
14511451
return $this->get($this->getProjectPath($project_id, 'access_tokens'));
14521452
}
14531453

1454+
/**
1455+
* @param int|string $project_id
1456+
* @param int|string $token_id
1457+
*
1458+
* @return mixed
1459+
*/
1460+
public function projectAccessToken($project_id, $token_id)
1461+
{
1462+
return $this->get($this->getProjectPath($project_id, 'access_tokens/'.self::encodePath($token_id)));
1463+
}
1464+
14541465
/**
14551466
* @param int|string $project_id
14561467
* @param array $parameters {

tests/Api/ProjectsTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,6 +2678,33 @@ public function shouldGetProjectAccessTokens(): void
26782678
$this->assertEquals($expectedArray, $api->projectAccessTokens(1));
26792679
}
26802680

2681+
/**
2682+
* @test
2683+
*/
2684+
public function shouldGetProjectAccessToken(): void
2685+
{
2686+
$expectedArray = [
2687+
'user_id' => 141,
2688+
'scopes' => [
2689+
'api',
2690+
],
2691+
'name' => 'token',
2692+
'expires_at' => '2021-01-31',
2693+
'id' => 42,
2694+
'active' => true,
2695+
'created_at' => '2021-01-20T22:11:48.151Z',
2696+
'revoked' => false,
2697+
];
2698+
2699+
$api = $this->getApiMock();
2700+
$api->expects($this->once())
2701+
->method('get')
2702+
->with('projects/1/access_tokens/42')
2703+
->will($this->returnValue($expectedArray));
2704+
2705+
$this->assertEquals($expectedArray, $api->projectAccessToken(1, 42));
2706+
}
2707+
26812708
/**
26822709
* @test
26832710
*/

0 commit comments

Comments
 (0)