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 @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add support for `job_inputs` and `job_variables_attributes` in `Jobs::play`
* Add support for filters in `Projects::projectAccessTokens`
* Add support for listing merge requests associated with a commit
* Add support for `without_project_bots` in `Users::all`


## [12.0.0] - 2025-02-23
Expand Down
23 changes: 14 additions & 9 deletions src/Api/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ class Users extends AbstractApi
/**
* @param array $parameters {
*
* @var string $search search for user by email or username
* @var string $username lookup for user by username
* @var bool $external search for external users only
* @var string $extern_uid lookup for users by external uid
* @var string $provider lookup for users by provider
* @var \DateTimeInterface $created_before return users created before the given time (inclusive)
* @var \DateTimeInterface $created_after return users created after the given time (inclusive)
* @var bool $active Return only active users. It does not support filtering inactive users.
* @var bool $blocked Return only blocked users. It does not support filtering non-blocked users.
* @var string $search search for user by email or username
* @var string $username lookup for user by username
* @var bool $external search for external users only
* @var string $extern_uid lookup for users by external uid
* @var string $provider lookup for users by provider
* @var \DateTimeInterface $created_before return users created before the given time (inclusive)
* @var \DateTimeInterface $created_after return users created after the given time (inclusive)
* @var bool $active Return only active users. It does not support filtering inactive users.
* @var bool $blocked Return only blocked users. It does not support filtering non-blocked users.
* @var bool $without_project_bots Exclude project and group bot users.
* }
*/
public function all(array $parameters = []): mixed
Expand Down Expand Up @@ -62,6 +63,10 @@ public function all(array $parameters = []): mixed
->setAllowedTypes('blocked', 'bool')
->setAllowedValues('blocked', true)
;
$resolver->setDefined('without_project_bots')
->setAllowedTypes('without_project_bots', 'bool')
->setAllowedValues('without_project_bots', true)
;

return $this->get('users', $resolver->resolve($parameters));
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Api/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ public function shouldGetActiveUsers(): void
$this->assertEquals($expectedArray, $api->all(['active' => true]));
}

#[Test]
public function shouldGetAllUsersWithoutProjectBots(): void
{
$expectedArray = [
['id' => 1, 'name' => 'Matt'],
['id' => 2, 'name' => 'John'],
];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('users', ['without_project_bots' => true])
->willReturn($expectedArray)
;

$this->assertEquals($expectedArray, $api->all(['without_project_bots' => true]));
}

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