Skip to content

Group: add parameters to show API call #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 12.0
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions src/Api/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/Api/GroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down