Skip to content

Commit 7e7634b

Browse files
GrahamCampbellIAL32
andcommitted
Fixed Projects::createPipeline() method
Closes #695 Co-Authored-By: Adrian Castro <[email protected]>
1 parent 0bb38c1 commit 7e7634b

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [11.7.1] - UPCOMING
9+
10+
* Fixed `Projects::createPipeline()` method
11+
812
## [11.7.0] - 2022-01-24
913

1014
* Dropped PHP 7.2 and 7.3 support

src/Api/AbstractApi.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ protected function get(string $uri, array $params = [], array $headers = [])
103103
* @param array<string,mixed> $params
104104
* @param array<string,string> $headers
105105
* @param array<string,string> $files
106+
* @param array<string,mixed> $uriParams
106107
*
107108
* @return mixed
108109
*/
109-
protected function post(string $uri, array $params = [], array $headers = [], array $files = [])
110+
protected function post(string $uri, array $params = [], array $headers = [], array $files = [], array $uriParams = [])
110111
{
111112
if (0 < \count($files)) {
112113
$builder = $this->createMultipartStreamBuilder($params, $files);
@@ -120,7 +121,7 @@ protected function post(string $uri, array $params = [], array $headers = [], ar
120121
}
121122
}
122123

123-
$response = $this->client->getHttpClient()->post(self::prepareUri($uri), $headers, $body);
124+
$response = $this->client->getHttpClient()->post(self::prepareUri($uri, $uriParams), $headers, $body);
124125

125126
return ResponseMediator::getContent($response);
126127
}

src/Api/Projects.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,15 @@ public function pipelineVariables($project_id, int $pipeline_id)
421421
*/
422422
public function createPipeline($project_id, string $commit_ref, array $variables = null)
423423
{
424-
$parameters = [
425-
'ref' => $commit_ref,
426-
];
424+
$parameters = [];
427425

428426
if (null !== $variables) {
429427
$parameters['variables'] = $variables;
430428
}
431429

432-
return $this->post($this->getProjectPath($project_id, 'pipeline'), $parameters);
430+
return $this->post($this->getProjectPath($project_id, 'pipeline'), $parameters, [], [], [
431+
'ref' => $commit_ref,
432+
]);
433433
}
434434

435435
/**

tests/Api/ProjectsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ public function shouldCreatePipeline(): void
839839
$api = $this->getApiMock();
840840
$api->expects($this->once())
841841
->method('post')
842-
->with('projects/1/pipeline', ['ref' => 'test-pipeline'])
842+
->with('projects/1/pipeline', [], [], [], ['ref' => 'test-pipeline'])
843843
->will($this->returnValue($expectedArray));
844844

845845
$this->assertEquals($expectedArray, $api->createPipeline(1, 'test-pipeline'));
@@ -868,7 +868,7 @@ public function shouldCreatePipelineWithVariables(): void
868868
$api = $this->getApiMock();
869869
$api->expects($this->once())
870870
->method('post')
871-
->with('projects/1/pipeline', ['ref' => 'test-pipeline', 'variables' => $variables])
871+
->with('projects/1/pipeline', ['variables' => $variables], [], [], ['ref' => 'test-pipeline'])
872872
->will($this->returnValue($expectedArray));
873873

874874
$this->assertEquals($expectedArray, $api->createPipeline(1, 'test-pipeline', $variables));

0 commit comments

Comments
 (0)