Skip to content

Commit 05bd375

Browse files
committed
Group: add parameters to show API call
1 parent 1bf5326 commit 05bd375

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/Api/Groups.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@ public function all(array $parameters = []): mixed
6767
return $this->get('groups', $resolver->resolve($parameters));
6868
}
6969

70-
public function show(int|string $id): mixed
70+
public function show(int|string $id, array $parameters = []): mixed
7171
{
72-
return $this->get('groups/'.self::encodePath($id));
72+
$resolver = $this->createOptionsResolver()
73+
->setDefined('with_custom_attributes')
74+
->setAllowedTypes('with_custom_attributes', 'bool')
75+
->setDefined('with_projects')
76+
->setAllowedTypes('with_projects', 'bool')
77+
;
78+
79+
return $this->get('groups/'.self::encodePath($id), $resolver->resolve($parameters));
7380
}
7481

7582
public function create(string $name, string $path, ?string $description = null, string $visibility = 'private', ?bool $lfs_enabled = null, ?bool $request_access_enabled = null, ?int $parent_id = null, ?int $shared_runners_minutes_limit = null): mixed

tests/Api/GroupsTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ public function shouldShowGroup(): void
125125
$this->assertEquals($expectedArray, $api->show(1));
126126
}
127127

128+
#[Test]
129+
public function shouldShowGroupWithAdditionalParameters(): void
130+
{
131+
$expectedArray = ['id' => 1, 'name' => 'A group'];
132+
$parameters = ['with_custom_attributes' => false, 'with_projects' => false];
133+
134+
$api = $this->getApiMock();
135+
$api->expects($this->once())
136+
->method('get')
137+
->with('groups/1', $parameters)
138+
->willReturn($expectedArray)
139+
;
140+
141+
$this->assertEquals($expectedArray, $api->show(1, $parameters));
142+
}
143+
128144
#[Test]
129145
public function shouldCreateGroup(): void
130146
{

0 commit comments

Comments
 (0)