Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add support for `without_project_bots` in `Users::all`
* Add support for date filters and `finished_at` ordering in `Deployments::all`
* Add support for listing merge requests associated with a deployment
* Add support for `with_custom_attributes` and `with_projects` in `Groups::show`


## [12.0.0] - 2025-02-23
Expand Down
25 changes: 23 additions & 2 deletions src/Api/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,30 @@ public function all(array $parameters = []): mixed
return $this->get('groups', $resolver->resolve($parameters));
}

public function show(int|string $id): mixed
/**
* @param array $parameters {
*
* @var bool $with_custom_attributes include custom attributes in response
* @var bool $with_projects Include details from projects that belong to the group.
* }
*/
public function show(int|string $id, array $parameters = []): mixed
{
return $this->get('groups/'.self::encodePath($id));
$resolver = $this->createOptionsResolver();
$booleanNormalizer = function (Options $resolver, $value): string {
return $value ? 'true' : 'false';
};

$resolver->setDefined('with_custom_attributes')
->setAllowedTypes('with_custom_attributes', 'bool')
->setNormalizer('with_custom_attributes', $booleanNormalizer)
;
$resolver->setDefined('with_projects')
->setAllowedTypes('with_projects', 'bool')
->setNormalizer('with_projects', $booleanNormalizer)
;

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
Expand Down
16 changes: 16 additions & 0 deletions tests/Api/GroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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' => true, 'with_projects' => false];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('groups/1', ['with_custom_attributes' => 'true', 'with_projects' => 'false'])
->willReturn($expectedArray)
;

$this->assertEquals($expectedArray, $api->show(1, $parameters));
}

#[Test]
public function shouldCreateGroup(): void
{
Expand Down