Skip to content

Commit 3467a34

Browse files
authored
feature KnpLabs#1082 Feat: Support new Team Repositories Endpoint (iBotPeaches)
This PR was squashed before being merged into the 3.9.x-dev branch. Discussion ---------- * old - https://docs.github.com/en/rest/teams/teams#list-team-repositories-legacy * new - https://docs.github.com/en/rest/teams/teams#list-team-repositories Commits ------- ca59785 refactor: support new team endpoint, fallback to legacy if no org 69e82d6 test: support new team endpoint, fallback to legacy if no org
1 parent e1c8cb9 commit 3467a34

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/Github/Api/Organization/Teams.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,16 @@ public function removeMember($team, $username, $organization)
9595
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
9696
}
9797

98-
public function repositories($team)
98+
/**
99+
* @link https://docs.github.com/en/rest/teams/teams#list-team-repositories
100+
*/
101+
public function repositories($team, $organization = '')
99102
{
100-
return $this->get('/teams/'.rawurlencode($team).'/repos');
103+
if (empty($organization)) {
104+
return $this->get('/teams/'.rawurlencode($team).'/repos');
105+
}
106+
107+
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos');
101108
}
102109

103110
public function repository($team, $organization, $repository)

test/Github/Tests/Api/Organization/TeamsTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ public function shouldGetTeamRepositories()
126126
{
127127
$expectedValue = [['name' => 'l3l0repo']];
128128

129+
$api = $this->getApiMock();
130+
$api->expects($this->once())
131+
->method('get')
132+
->with('/orgs/KnpLabs/teams/KnpWorld/repos')
133+
->will($this->returnValue($expectedValue));
134+
135+
$this->assertEquals($expectedValue, $api->repositories('KnpWorld', 'KnpLabs'));
136+
}
137+
138+
/**
139+
* @test
140+
*/
141+
public function shouldGetTeamRepositoriesViaLegacy()
142+
{
143+
$expectedValue = [['name' => 'l3l0repo']];
144+
129145
$api = $this->getApiMock();
130146
$api->expects($this->once())
131147
->method('get')

0 commit comments

Comments
 (0)