Skip to content

Commit 802bd7c

Browse files
committed
fix optional params on MR create
1 parent 3da3c1c commit 802bd7c

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

lib/Gitlab/Api/MergeRequests.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,16 @@ public function show($project_id, $mr_id)
109109
* @param string $source
110110
* @param string $target
111111
* @param string $title
112-
* @param int $assignee
113-
* @param int $target_project_id
114-
* @param string $description
112+
* @param array $extraParams
115113
* @return mixed
116114
*/
117-
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null)
115+
public function create($project_id, $source, $target, $title, array $extraParams = [])
118116
{
119-
return $this->post($this->getProjectPath($project_id, 'merge_requests'), array(
117+
return $this->post($this->getProjectPath($project_id, 'merge_requests'), array_merge([
120118
'source_branch' => $source,
121119
'target_branch' => $target,
122120
'title' => $title,
123-
'assignee_id' => $assignee,
124-
'target_project_id' => $target_project_id,
125-
'description' => $description
126-
));
121+
], $extraParams));
127122
}
128123

129124
/**

test/Gitlab/Tests/Api/MergeRequestsTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ public function shouldCreateMergeRequestWithoutOptionalParams()
123123
'title' => 'Merge Request',
124124
'target_branch' => 'master',
125125
'source_branch' => 'develop',
126-
'description' => null,
127-
'assignee_id' => null,
128-
'target_project_id' => null
129126
))
130127
->will($this->returnValue($expectedArray))
131128
;
@@ -154,7 +151,13 @@ public function shouldCreateMergeRequestWithOptionalParams()
154151
->will($this->returnValue($expectedArray))
155152
;
156153

157-
$this->assertEquals($expectedArray, $api->create(1, 'develop', 'master', 'Merge Request', 6, 20, 'Some changes'));
154+
$extraParams = [
155+
'assignee_id' => 6,
156+
'target_project_id' => 20,
157+
'description' => 'Some changes',
158+
];
159+
160+
$this->assertEquals($expectedArray, $api->create(1, 'develop', 'master', 'Merge Request', $extraParams));
158161
}
159162

160163
/**

0 commit comments

Comments
 (0)