Skip to content

Commit 7fdd65f

Browse files
Merge branch '11.11' into 11.12
2 parents e483585 + 10cc6af commit 7fdd65f

File tree

9 files changed

+291
-2
lines changed

9 files changed

+291
-2
lines changed

.styleci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ enabled:
1010
- declare_strict_types
1111
- native_constant_invocation
1212
- native_function_invocation
13-
- phpdoc_align
1413
- phpdoc_order
1514
- void_return
1615

1716
disabled:
1817
- native_constant_invocation_symfony
1918
- native_function_invocation_symfony
2019
- no_superfluous_phpdoc_tags_symfony
20+
- phpdoc_align
2121
- phpdoc_to_comment
2222
- phpdoc_var_without_name

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [11.11.0] - UPCOMING
99

1010
* Add support for `author_id` in `Issues::all`
11+
* Add support for `tier` in `Environments::create`
1112
* Add support for `expires_at` in `Groups::addMember`
1213
* Add support for `include_retried` in `Jobs::pipelineBridges`
1314
* Add support for additional parameters in `Projects::deployment`
15+
* Add support for additional parameters in `Projects::forks`
16+
* Add support for `Events::all`
1417
* Add support for `Users::removeUserIdentity`
1518
* Add support for `MergeRequests::showParticipants`
1619

src/Api/Environments.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function all($project_id, array $parameters = [])
4444
*
4545
* @var string $name The name of the environment
4646
* @var string $external_url Place to link to for this environment
47+
* @var string $tier The tier of the new environment. Allowed values are production, staging, testing, development, and other.
4748
* }
4849
*
4950
* @return mixed
@@ -56,6 +57,8 @@ public function create($project_id, array $parameters = [])
5657
->setAllowedTypes('name', 'string');
5758
$resolver->setDefined('external_url')
5859
->setAllowedTypes('external_url', 'string');
60+
$resolver->setDefined('tier')
61+
->setAllowedValues('tier', ['production', 'staging', 'testing', 'development', 'other']);
5962

6063
return $this->post($this->getProjectPath($project_id, 'environments'), $resolver->resolve($parameters));
6164
}

src/Api/Events.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Gitlab API library.
7+
*
8+
* (c) Niclas Hoyer <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Gitlab\Api;
15+
16+
use Symfony\Component\OptionsResolver\Options;
17+
18+
class Events extends AbstractApi
19+
{
20+
/**
21+
* @param array $parameters {
22+
*
23+
* @var string $action include only events of a particular action type
24+
* @var string $target_type include only events of a particular target type
25+
* @var \DateTimeInterface $before include only events created before a particular date
26+
* @var \DateTimeInterface $after include only events created after a particular date
27+
* @var string $scope include all events across a user’s projects
28+
* @var string $sort sort events in asc or desc order by created_at
29+
*
30+
* }
31+
*
32+
* @return mixed
33+
*/
34+
public function all(array $parameters = [])
35+
{
36+
$resolver = $this->createOptionsResolver();
37+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value): string {
38+
return $value->format('Y-m-d');
39+
};
40+
41+
$resolver->setDefined('action');
42+
$resolver->setDefined('target_type');
43+
$resolver->setDefined('before')
44+
->setAllowedTypes('before', \DateTimeInterface::class)
45+
->setNormalizer('before', $datetimeNormalizer)
46+
;
47+
$resolver->setDefined('after')
48+
->setAllowedTypes('after', \DateTimeInterface::class)
49+
->setNormalizer('after', $datetimeNormalizer)
50+
;
51+
$resolver->setDefined('scope');
52+
$resolver->setDefined('sort');
53+
54+
return $this->get('events', $resolver->resolve($parameters));
55+
}
56+
}

src/Api/Projects.php

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,13 +1035,100 @@ public function languages($project_id)
10351035

10361036
/**
10371037
* @param int|string $project_id
1038-
* @param array $parameters
1038+
* @param array $parameters {
1039+
*
1040+
* @var bool $archived Limit by archived status
1041+
* @var string $visibility Limit by visibility public, internal, or private
1042+
* @var string $order_by Return projects ordered by id, name, path, created_at, updated_at,
1043+
* last_activity_at, repository_size, storage_size, packages_size or
1044+
* wiki_size fields (default is created_at)
1045+
* @var string $sort Return projects sorted in asc or desc order (default is desc)
1046+
* @var string $search Return list of projects matching the search criteria
1047+
* @var bool $simple Return only the ID, URL, name, and path of each project
1048+
* @var bool $owned Limit by projects owned by the current user
1049+
* @var bool $membership Limit by projects that the current user is a member of
1050+
* @var bool $starred Limit by projects starred by the current user
1051+
* @var bool $statistics Include project statistics
1052+
* @var bool $with_issues_enabled Limit by enabled issues feature
1053+
* @var bool $with_merge_requests_enabled Limit by enabled merge requests feature
1054+
* @var int $min_access_level Limit by current user minimal access level
1055+
* @var \DateTimeInterface $updated_before limit results to projects last updated before the specified time
1056+
* @var \DateTimeInterface $updated_after limit results to projects last updated after the specified time
1057+
* @var bool $with_custom_attributes Include custom attributes in response
1058+
* }
10391059
*
10401060
* @return mixed
10411061
*/
10421062
public function forks($project_id, array $parameters = [])
10431063
{
10441064
$resolver = $this->createOptionsResolver();
1065+
$booleanNormalizer = function (Options $resolver, $value): string {
1066+
return $value ? 'true' : 'false';
1067+
};
1068+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value): string {
1069+
return $value->format('c');
1070+
};
1071+
$resolver->setDefined('archived')
1072+
->setAllowedTypes('archived', 'bool')
1073+
->setNormalizer('archived', $booleanNormalizer)
1074+
;
1075+
$resolver->setDefined('visibility')
1076+
->setAllowedValues('visibility', ['public', 'internal', 'private'])
1077+
;
1078+
$orderBy = [
1079+
'id', 'name', 'path', 'created_at', 'updated_at', 'last_activity_at',
1080+
'repository_size', 'storage_size', 'packages_size', 'wiki_size',
1081+
];
1082+
$resolver->setDefined('order_by')
1083+
->setAllowedValues('order_by', $orderBy)
1084+
;
1085+
$resolver->setDefined('sort')
1086+
->setAllowedValues('sort', ['asc', 'desc'])
1087+
;
1088+
$resolver->setDefined('search');
1089+
$resolver->setDefined('simple')
1090+
->setAllowedTypes('simple', 'bool')
1091+
->setNormalizer('simple', $booleanNormalizer)
1092+
;
1093+
$resolver->setDefined('owned')
1094+
->setAllowedTypes('owned', 'bool')
1095+
->setNormalizer('owned', $booleanNormalizer)
1096+
;
1097+
$resolver->setDefined('membership')
1098+
->setAllowedTypes('membership', 'bool')
1099+
->setNormalizer('membership', $booleanNormalizer)
1100+
;
1101+
$resolver->setDefined('starred')
1102+
->setAllowedTypes('starred', 'bool')
1103+
->setNormalizer('starred', $booleanNormalizer)
1104+
;
1105+
$resolver->setDefined('statistics')
1106+
->setAllowedTypes('statistics', 'bool')
1107+
->setNormalizer('statistics', $booleanNormalizer)
1108+
;
1109+
$resolver->setDefined('with_issues_enabled')
1110+
->setAllowedTypes('with_issues_enabled', 'bool')
1111+
->setNormalizer('with_issues_enabled', $booleanNormalizer)
1112+
;
1113+
$resolver->setDefined('with_merge_requests_enabled')
1114+
->setAllowedTypes('with_merge_requests_enabled', 'bool')
1115+
->setNormalizer('with_merge_requests_enabled', $booleanNormalizer)
1116+
;
1117+
$resolver->setDefined('min_access_level')
1118+
->setAllowedValues('min_access_level', [null, 10, 20, 30, 40, 50])
1119+
;
1120+
$resolver->setDefined('updated_before')
1121+
->setAllowedTypes('updated_before', \DateTimeInterface::class)
1122+
->setNormalizer('updated_before', $datetimeNormalizer)
1123+
;
1124+
$resolver->setDefined('updated_after')
1125+
->setAllowedTypes('updated_after', \DateTimeInterface::class)
1126+
->setNormalizer('updated_after', $datetimeNormalizer)
1127+
;
1128+
$resolver->setDefined('with_custom_attributes')
1129+
->setAllowedTypes('with_custom_attributes', 'bool')
1130+
->setNormalizer('with_custom_attributes', $booleanNormalizer)
1131+
;
10451132

10461133
return $this->get($this->getProjectPath($project_id, 'forks'), $resolver->resolve($parameters));
10471134
}

src/Client.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Gitlab\Api\DeployKeys;
1818
use Gitlab\Api\Deployments;
1919
use Gitlab\Api\Environments;
20+
use Gitlab\Api\Events;
2021
use Gitlab\Api\Groups;
2122
use Gitlab\Api\GroupsBoards;
2223
use Gitlab\Api\GroupsEpics;
@@ -174,6 +175,14 @@ public function environments(): Environments
174175
return new Environments($this);
175176
}
176177

178+
/**
179+
* @return Events
180+
*/
181+
public function events(): Events
182+
{
183+
return new Events($this);
184+
}
185+
177186
/**
178187
* @return Groups
179188
*/

tests/Api/EnvironmentsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ public function shouldCreateEnvironment(): void
155155
'name' => 'review/fix-baz',
156156
'slug' => 'review-fix-baz-dfjre5',
157157
'external_url' => 'https://review-fix-baz-dfjre5.example.gitlab.com',
158+
'tier' => 'production',
158159
],
159160
];
160161

161162
$params = [
162163
'name' => 'review/fix-baz',
163164
'external_url' => 'https://review-fix-baz-dfjre5.example.gitlab.com',
165+
'tier' => 'production',
164166
];
165167

166168
$api = $this->getApiMock();

tests/Api/EventsTest.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Gitlab API library.
7+
*
8+
* (c) Niclas Hoyer <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Gitlab\Tests\Api;
15+
16+
use Gitlab\Api\Events;
17+
18+
class EventsTest extends TestCase
19+
{
20+
protected function getApiClass()
21+
{
22+
return Events::class;
23+
}
24+
25+
/**
26+
* @test
27+
*/
28+
public function shouldGetAllEvents(): void
29+
{
30+
$expectedArray = [
31+
['id' => 1, 'target_type' => 'Issue'],
32+
['id' => 2, 'target_type' => null],
33+
];
34+
35+
$api = $this->getApiMock();
36+
$api->expects($this->once())
37+
->method('get')
38+
->with('events', [])
39+
->will($this->returnValue($expectedArray))
40+
;
41+
42+
$this->assertEquals($expectedArray, $api->all());
43+
}
44+
45+
/**
46+
* @test
47+
*/
48+
public function shouldGetEventsAfter(): void
49+
{
50+
$expectedArray = [
51+
['id' => 1, 'target_type' => 'Issue'],
52+
['id' => 2, 'target_type' => null],
53+
];
54+
55+
$api = $this->getApiMock();
56+
$api->expects($this->once())
57+
->method('get')
58+
->with('events', ['after' => '1970-01-01'])
59+
->will($this->returnValue($expectedArray))
60+
;
61+
62+
$this->assertEquals($expectedArray, $api->all(['after' => new \DateTime('1970-01-01')]));
63+
}
64+
}

tests/Api/ProjectsTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,71 @@ public function shouldGetForks(): void
19361936
$this->assertEquals($expectedArray, $api->forks(1));
19371937
}
19381938

1939+
/**
1940+
* @test
1941+
*/
1942+
public function shouldGetForksUsingParameters(): void
1943+
{
1944+
$expectedArray = [
1945+
[
1946+
'id' => 2,
1947+
'forked_from_project' => [
1948+
'id' => 1,
1949+
],
1950+
],
1951+
[
1952+
'id' => 3,
1953+
'forked_from_project' => [
1954+
'id' => 1,
1955+
],
1956+
],
1957+
];
1958+
$updated_after = new \DateTime('2018-01-01 00:00:00');
1959+
$updated_before = new \DateTime('2018-01-31 00:00:00');
1960+
1961+
$api = $this->getApiMock();
1962+
$api->expects($this->once())
1963+
->method('get')
1964+
->with('projects/1/forks', [
1965+
'archived' => 'false',
1966+
'visibility' => 'public',
1967+
'order_by' => 'id',
1968+
'sort' => 'asc',
1969+
'search' => 'term',
1970+
'simple' => 'true',
1971+
'owned' => 'false',
1972+
'membership' => 'false',
1973+
'starred' => 'false',
1974+
'statistics' => 'false',
1975+
'with_issues_enabled' => 'false',
1976+
'with_merge_requests_enabled' => 'false',
1977+
'min_access_level' => 30,
1978+
'updated_after' => $updated_after->format('c'),
1979+
'updated_before' => $updated_before->format('c'),
1980+
'with_custom_attributes' => 'true',
1981+
])
1982+
->will($this->returnValue($expectedArray));
1983+
1984+
$this->assertEquals($expectedArray, $api->forks(1, [
1985+
'archived' => false,
1986+
'visibility' => 'public',
1987+
'order_by' => 'id',
1988+
'sort' => 'asc',
1989+
'search' => 'term',
1990+
'simple' => true,
1991+
'owned' => false,
1992+
'membership' => false,
1993+
'starred' => false,
1994+
'statistics' => false,
1995+
'with_issues_enabled' => false,
1996+
'with_merge_requests_enabled' => false,
1997+
'min_access_level' => 30,
1998+
'updated_after' => $updated_after,
1999+
'updated_before' => $updated_before,
2000+
'with_custom_attributes' => true,
2001+
]));
2002+
}
2003+
19392004
/**
19402005
* @test
19412006
*/

0 commit comments

Comments
 (0)