diff --git a/src/Api/Groups.php b/src/Api/Groups.php index 7104d345..1be3c415 100644 --- a/src/Api/Groups.php +++ b/src/Api/Groups.php @@ -67,9 +67,16 @@ public function all(array $parameters = []): mixed return $this->get('groups', $resolver->resolve($parameters)); } - public function show(int|string $id): mixed + public function show(int|string $id, array $parameters = []): mixed { - return $this->get('groups/'.self::encodePath($id)); + $resolver = $this->createOptionsResolver() + ->setDefined('with_custom_attributes') + ->setAllowedTypes('with_custom_attributes', 'bool') + ->setDefined('with_projects') + ->setAllowedTypes('with_projects', 'bool') + ; + + return $this->get('groups/'.self::encodePath($id), $resolver->resolve($parameters)); } 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 diff --git a/tests/Api/GroupsTest.php b/tests/Api/GroupsTest.php index 3b90e6f2..a508551c 100644 --- a/tests/Api/GroupsTest.php +++ b/tests/Api/GroupsTest.php @@ -125,6 +125,22 @@ public function shouldShowGroup(): void $this->assertEquals($expectedArray, $api->show(1)); } + #[Test] + public function shouldShowGroupWithAdditionalParameters(): void + { + $expectedArray = ['id' => 1, 'name' => 'A group']; + $parameters = ['with_custom_attributes' => false, 'with_projects' => false]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('groups/1', $parameters) + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->show(1, $parameters)); + } + #[Test] public function shouldCreateGroup(): void {