From 7e7634b5fc332a96ed4ce72dc26cfa21ee6174eb Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 24 Apr 2022 19:46:36 +0100 Subject: [PATCH 1/5] Fixed `Projects::createPipeline()` method Closes #695 Co-Authored-By: Adrian Castro <562969+IAL32@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ src/Api/AbstractApi.php | 5 +++-- src/Api/Projects.php | 8 ++++---- tests/Api/ProjectsTest.php | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b63d5419..a0e4ed03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [11.7.1] - UPCOMING + +* Fixed `Projects::createPipeline()` method + ## [11.7.0] - 2022-01-24 * Dropped PHP 7.2 and 7.3 support diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 70f899ad..5c81d6fd 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -103,10 +103,11 @@ protected function get(string $uri, array $params = [], array $headers = []) * @param array $params * @param array $headers * @param array $files + * @param array $uriParams * * @return mixed */ - protected function post(string $uri, array $params = [], array $headers = [], array $files = []) + protected function post(string $uri, array $params = [], array $headers = [], array $files = [], array $uriParams = []) { if (0 < \count($files)) { $builder = $this->createMultipartStreamBuilder($params, $files); @@ -120,7 +121,7 @@ protected function post(string $uri, array $params = [], array $headers = [], ar } } - $response = $this->client->getHttpClient()->post(self::prepareUri($uri), $headers, $body); + $response = $this->client->getHttpClient()->post(self::prepareUri($uri, $uriParams), $headers, $body); return ResponseMediator::getContent($response); } diff --git a/src/Api/Projects.php b/src/Api/Projects.php index fe067dd6..e824cc2f 100644 --- a/src/Api/Projects.php +++ b/src/Api/Projects.php @@ -421,15 +421,15 @@ public function pipelineVariables($project_id, int $pipeline_id) */ public function createPipeline($project_id, string $commit_ref, array $variables = null) { - $parameters = [ - 'ref' => $commit_ref, - ]; + $parameters = []; if (null !== $variables) { $parameters['variables'] = $variables; } - return $this->post($this->getProjectPath($project_id, 'pipeline'), $parameters); + return $this->post($this->getProjectPath($project_id, 'pipeline'), $parameters, [], [], [ + 'ref' => $commit_ref, + ]); } /** diff --git a/tests/Api/ProjectsTest.php b/tests/Api/ProjectsTest.php index 200de417..113c69c9 100644 --- a/tests/Api/ProjectsTest.php +++ b/tests/Api/ProjectsTest.php @@ -839,7 +839,7 @@ public function shouldCreatePipeline(): void $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('projects/1/pipeline', ['ref' => 'test-pipeline']) + ->with('projects/1/pipeline', [], [], [], ['ref' => 'test-pipeline']) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->createPipeline(1, 'test-pipeline')); @@ -868,7 +868,7 @@ public function shouldCreatePipelineWithVariables(): void $api = $this->getApiMock(); $api->expects($this->once()) ->method('post') - ->with('projects/1/pipeline', ['ref' => 'test-pipeline', 'variables' => $variables]) + ->with('projects/1/pipeline', ['variables' => $variables], [], [], ['ref' => 'test-pipeline']) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->createPipeline(1, 'test-pipeline', $variables)); From 4008018442dbf6f78feeb0d814ccbb4177467763 Mon Sep 17 00:00:00 2001 From: Jure Jager Date: Sun, 24 Apr 2022 20:48:19 +0200 Subject: [PATCH 2/5] Fix epic's states (#697) --- src/Api/GroupsEpics.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Api/GroupsEpics.php b/src/Api/GroupsEpics.php index e66e9730..b6ab2cdc 100644 --- a/src/Api/GroupsEpics.php +++ b/src/Api/GroupsEpics.php @@ -19,7 +19,12 @@ class GroupsEpics extends AbstractApi /** * @var string */ - public const STATE_ACTIVE = 'active'; + public const STATE_ALL = 'all'; + + /** + * @var string + */ + public const STATE_OPENED = 'opened'; /** * @var string @@ -47,7 +52,7 @@ public function all($group_id, array $parameters = []) }) ; $resolver->setDefined('state') - ->setAllowedValues('state', [self::STATE_ACTIVE, self::STATE_CLOSED]) + ->setAllowedValues('state', [self::STATE_ALL, self::STATE_OPENED, self::STATE_CLOSED]) ; $resolver->setDefined('search'); From 5ac6cb12fa242370ec33df02183a1374b8409cac Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 24 Apr 2022 19:48:40 +0100 Subject: [PATCH 3/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e4ed03..84a2ac5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [11.7.1] - UPCOMING +* Fixed `GroupsEpic::all()` method * Fixed `Projects::createPipeline()` method ## [11.7.0] - 2022-01-24 From a1a72294cbccfd1620766d0d3d1bd1d821d5c5a2 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 24 Apr 2022 19:53:12 +0100 Subject: [PATCH 4/5] Fixes --- tests/HttpClient/Message/ResponseMediatorTest.php | 7 +------ tests/IntegrationTest.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/HttpClient/Message/ResponseMediatorTest.php b/tests/HttpClient/Message/ResponseMediatorTest.php index 4596ee24..7266ecfa 100644 --- a/tests/HttpClient/Message/ResponseMediatorTest.php +++ b/tests/HttpClient/Message/ResponseMediatorTest.php @@ -75,12 +75,7 @@ public function testGetErrrorMessageInvalidJson(): void public function testGetPagination(): void { - $header = <<<'TEXT' -; rel="first", -; rel="next", -; rel="prev", -; rel="last", -TEXT; + $header = '; rel="first",; rel="next",; rel="prev",; rel="last"'; $pagination = [ 'first' => 'https://example.gitlab.com/', diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 910aeaa3..e095c4ea 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -26,7 +26,7 @@ public function testRepoContributors(): void $response = $client ->repositories() - ->contributors(5315609); + ->contributors(16155465); $this->assertIsArray($response); $this->assertTrue(isset($response[2])); From 8c8d944d3a9fa55a38794df56938cad523c8896b Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 24 Apr 2022 19:54:16 +0100 Subject: [PATCH 5/5] Release 11.7.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84a2ac5e..4e903b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [11.7.1] - UPCOMING +## [11.7.1] - 2022-04-24 * Fixed `GroupsEpic::all()` method * Fixed `Projects::createPipeline()` method