Skip to content

Commit 2c7fbbf

Browse files
committed
Team: Can Access All Packages
1 parent 28985a1 commit 2c7fbbf

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

src/Api/Teams.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function all()
1818
return $this->get('/teams/');
1919
}
2020

21-
public function create(string $name, TeamPermissions $permissions): array
21+
public function create(string $name, TeamPermissions $permissions, bool $canAccessAllPackages = false): array
2222
{
2323
$parameters = [
2424
'name' => $name,
@@ -29,6 +29,7 @@ public function create(string $name, TeamPermissions $permissions): array
2929
'canViewVendorCustomers' => (bool) $permissions->canViewVendorCustomers,
3030
'canManageVendorCustomers' => (bool) $permissions->canManageVendorCustomers,
3131
],
32+
'canAccessAllPackages' => $canAccessAllPackages,
3233
];
3334

3435
return $this->post('/teams/', $parameters);
@@ -39,7 +40,7 @@ public function show($teamId)
3940
return $this->get(sprintf('/teams/%s/', $teamId));
4041
}
4142

42-
public function edit($teamId, string $name, TeamPermissions $permissions): array
43+
public function edit($teamId, string $name, TeamPermissions $permissions, ?bool $canAccessAllPackages = null): array
4344
{
4445
$parameters = [
4546
'name' => $name,
@@ -51,6 +52,9 @@ public function edit($teamId, string $name, TeamPermissions $permissions): array
5152
'canManageVendorCustomers' => (bool) $permissions->canManageVendorCustomers,
5253
],
5354
];
55+
if ($canAccessAllPackages !== null) {
56+
$parameters['canAccessAllPackages'] = $canAccessAllPackages;
57+
}
5458

5559
return $this->put(sprintf('/teams/%s/', $teamId), $parameters);
5660
}

tests/Api/TeamsTest.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function testCreateTeam(): void
106106
'canViewVendorCustomers' => true,
107107
'canManageVendorCustomers' => false,
108108
],
109+
'canAccessAllPackages' => false,
109110
];
110111

111112
/** @var Teams&MockObject $api */
@@ -121,6 +122,7 @@ public function testCreateTeam(): void
121122
'canViewVendorCustomers' => true,
122123
'canManageVendorCustomers' => false,
123124
],
125+
'canAccessAllPackages' => false,
124126
]))
125127
->willReturn($expected);
126128

@@ -157,7 +159,7 @@ public function testShowTeam(): void
157159
$this->assertSame($expected, $api->show(123));
158160
}
159161

160-
public function testEditTeam(): void
162+
public function testEditTeamLegacy(): void
161163
{
162164
$expected = [
163165
'id' => 123,
@@ -193,6 +195,44 @@ public function testEditTeam(): void
193195
$this->assertSame($expected, $api->edit(123, 'New Team', $permissions));
194196
}
195197

198+
public function testEditTeam(): void
199+
{
200+
$expected = [
201+
'id' => 123,
202+
'name' => 'New Team',
203+
'permissions' => [
204+
'canEditTeamPackages' => true,
205+
'canAddPackages' => false,
206+
'canCreateSubrepositories' => false,
207+
'canViewVendorCustomers' => true,
208+
'canManageVendorCustomers' => false,
209+
],
210+
'canAccessAllPackages' => true,
211+
];
212+
213+
/** @var Teams&MockObject $api */
214+
$api = $this->getApiMock();
215+
$api->expects($this->once())
216+
->method('put')
217+
->with($this->equalTo('/teams/123/'), $this->equalTo([
218+
'name' => 'New Team',
219+
'permissions' => [
220+
'canEditTeamPackages' => true,
221+
'canAddPackages' => false,
222+
'canCreateSubrepositories' => false,
223+
'canViewVendorCustomers' => true,
224+
'canManageVendorCustomers' => false,
225+
],
226+
'canAccessAllPackages' => true,
227+
]))
228+
->willReturn($expected);
229+
230+
$permissions = new TeamPermissions;
231+
$permissions->canEditTeamPackages = true;
232+
$permissions->canViewVendorCustomers = true;
233+
$this->assertSame($expected, $api->edit(123, 'New Team', $permissions, true));
234+
}
235+
196236
public function testDeleteTeam(): void
197237
{
198238
$expected = [];

0 commit comments

Comments
 (0)