Skip to content

Commit 61b03b3

Browse files
author
Matt Humphrey
committed
Added merge request tests
1 parent 41457f0 commit 61b03b3

File tree

3 files changed

+349
-14
lines changed

3 files changed

+349
-14
lines changed

lib/Gitlab/Api/MergeRequests.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ class MergeRequests extends AbstractApi
1212

1313
/**
1414
* @param int $project_id
15+
* @param string $state
1516
* @param int $page
1617
* @param int $per_page
17-
* @param string $state
1818
* @param string $order_by
1919
* @param string $sort
2020
* @return mixed
2121
*/
22-
public function getList($project_id, $page, $per_page, $state = self::STATE_ALL, $order_by = self::ORDER_BY, $sort = self::SORT)
22+
public function getList($project_id, $state = self::STATE_ALL, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
2323
{
2424
return $this->get($this->getProjectPath($project_id, 'merge_requests'), array(
2525
'page' => $page,
@@ -40,7 +40,7 @@ public function getList($project_id, $page, $per_page, $state = self::STATE_ALL,
4040
*/
4141
public function all($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
4242
{
43-
return $this->getList($project_id, $page, $per_page, self::STATE_ALL, $order_by, $sort);
43+
return $this->getList($project_id, self::STATE_ALL, $page, $per_page, $order_by, $sort);
4444
}
4545

4646
/**
@@ -53,7 +53,7 @@ public function all($project_id, $page = 1, $per_page = self::PER_PAGE, $order_b
5353
*/
5454
public function merged($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
5555
{
56-
return $this->getList($project_id, $page, $per_page, self::STATE_MERGED, $order_by, $sort);
56+
return $this->getList($project_id, self::STATE_MERGED, $page, $per_page, $order_by, $sort);
5757
}
5858

5959
/**
@@ -66,7 +66,7 @@ public function merged($project_id, $page = 1, $per_page = self::PER_PAGE, $orde
6666
*/
6767
public function opened($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
6868
{
69-
return $this->getList($project_id, $page, $per_page, self::STATE_OPENED, $order_by, $sort);
69+
return $this->getList($project_id, self::STATE_OPENED, $page, $per_page, $order_by, $sort);
7070
}
7171

7272
/**
@@ -79,7 +79,7 @@ public function opened($project_id, $page = 1, $per_page = self::PER_PAGE, $orde
7979
*/
8080
public function closed($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
8181
{
82-
return $this->getList($project_id, $page, $per_page, self::STATE_CLOSED, $order_by, $sort);
82+
return $this->getList($project_id, self::STATE_CLOSED, $page, $per_page, $order_by, $sort);
8383
}
8484

8585
/**
@@ -104,10 +104,6 @@ public function show($project_id, $mr_id)
104104
*/
105105
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null)
106106
{
107-
if ($target_project_id && ! is_numeric($target_project_id)) {
108-
throw new \InvalidArgumentException('target_project_id should be numeric, the project name is not allowed');
109-
}
110-
111107
return $this->post($this->getProjectPath($project_id, 'merge_requests'), array(
112108
'source_branch' => $source,
113109
'target_branch' => $target,
@@ -132,11 +128,17 @@ public function update($project_id, $mr_id, array $params)
132128
/**
133129
* @param int $project_id
134130
* @param int $mr_id
135-
* @param array $params
131+
* @param string $message
136132
* @return mixed
137133
*/
138-
public function merge($project_id, $mr_id, array $params)
134+
public function merge($project_id, $mr_id, $message = null)
139135
{
136+
if (is_array($message)) {
137+
$params = $message;
138+
} else {
139+
$params = array('merge_commit_message' => $message);
140+
}
141+
140142
return $this->put($this->getProjectPath($project_id, 'merge_request/'.urlencode($mr_id).'/merge'), $params);
141143
}
142144

0 commit comments

Comments
 (0)