Skip to content

Commit 1924cd5

Browse files
authored
Merge pull request #354 from sidneymarieanne/fix-create-list-in-issues-board
Fix create list in issues board
2 parents a838d2d + 1b1435a commit 1924cd5

File tree

2 files changed

+134
-117
lines changed

2 files changed

+134
-117
lines changed

lib/Gitlab/Api/IssueBoards.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public function allLists($project_id, $board_id)
6868
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'));
6969
}
7070

71-
7271
/**
7372
* @param int $project_id
7473
* @param int $board_id
@@ -77,7 +76,7 @@ public function allLists($project_id, $board_id)
7776
*/
7877
public function showList($project_id, $board_id, $list_id)
7978
{
80-
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'.$this->encodePath($list_id)));
79+
return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists/'.$this->encodePath($list_id)));
8180
}
8281

8382
/**
@@ -105,9 +104,6 @@ public function createList($project_id, $board_id, $label_id)
105104
public function updateList($project_id, $board_id, $list_id, $position)
106105
{
107106
$params = array(
108-
'id' => $project_id,
109-
'board_id' => $board_id,
110-
'list_id' => $list_id,
111107
'position' => $position
112108
);
113109

test/Gitlab/Tests/Api/IssueBoardsTest.php

Lines changed: 133 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,7 @@ public function shouldGetAllBoards()
2121

2222
$this->assertEquals($expectedArray, $api->all());
2323
}
24-
//
25-
// /**
26-
// * @test
27-
// */
28-
// public function shouldGetProjectIssuesWithPagination()
29-
// {
30-
// $expectedArray = array(
31-
// array('id' => 1, 'title' => 'An issue'),
32-
// array('id' => 2, 'title' => 'Another issue'),
33-
// );
34-
//
35-
// $api = $this->getApiMock();
36-
// $api->expects($this->once())
37-
// ->method('get')
38-
// ->with('projects/1/issues', array('page' => 2, 'per_page' => 5))
39-
// ->will($this->returnValue($expectedArray))
40-
// ;
41-
//
42-
// $this->assertEquals($expectedArray, $api->all(1, 2, 5));
43-
// }
44-
//
45-
// /**
46-
// * @test
47-
// */
48-
// public function shouldGetProjectIssuesWithParams()
49-
// {
50-
// $expectedArray = array(
51-
// array('id' => 1, 'title' => 'An issue'),
52-
// array('id' => 2, 'title' => 'Another issue'),
53-
// );
54-
//
55-
// $api = $this->getApiMock();
56-
// $api->expects($this->once())
57-
// ->method('get')
58-
// ->with('projects/1/issues', array('page' => 2, 'per_page' => 5, 'order_by' => 'created_at', 'sort' => 'desc', 'labels' => 'foo,bar', 'state' => 'open'))
59-
// ->will($this->returnValue($expectedArray))
60-
// ;
61-
//
62-
// $this->assertEquals($expectedArray, $api->all(1, 2, 5, array('order_by' => 'created_at', 'sort' => 'desc', 'labels' => 'foo,bar', 'state' => 'open')));
63-
// }
64-
24+
6525
/**
6626
* @test
6727
*/
@@ -130,77 +90,138 @@ public function shouldRemoveIssueBoard()
13090
$this->assertEquals($expectedBool, $api->remove(1, 2));
13191
}
13292

133-
// /**
134-
// * @test
135-
// */
136-
// public function shouldGetIssueComments()
137-
// {
138-
// $expectedArray = array(
139-
// array('id' => 1, 'body' => 'A comment'),
140-
// array('id' => 2, 'body' => 'Another comment')
141-
// );
142-
//
143-
// $api = $this->getApiMock();
144-
// $api->expects($this->once())
145-
// ->method('get')
146-
// ->with('projects/1/issues/2/notes')
147-
// ->will($this->returnValue($expectedArray))
148-
// ;
149-
//
150-
// $this->assertEquals($expectedArray, $api->showComments(1, 2));
151-
// }
152-
//
153-
// /**
154-
// * @test
155-
// */
156-
// public function shouldGetIssueComment()
157-
// {
158-
// $expectedArray = array('id' => 3, 'body' => 'A new comment');
159-
//
160-
// $api = $this->getApiMock();
161-
// $api->expects($this->once())
162-
// ->method('get')
163-
// ->with('projects/1/issues/2/notes/3')
164-
// ->will($this->returnValue($expectedArray))
165-
// ;
166-
//
167-
// $this->assertEquals($expectedArray, $api->showComment(1, 2, 3));
168-
// }
169-
//
170-
// /**
171-
// * @test
172-
// */
173-
// public function shouldCreateComment()
174-
// {
175-
// $expectedArray = array('id' => 3, 'body' => 'A new comment');
176-
//
177-
// $api = $this->getApiMock();
178-
// $api->expects($this->exactly(2))
179-
// ->method('post')
180-
// ->with('projects/1/issues/2/notes', array('body' => 'A new comment'))
181-
// ->will($this->returnValue($expectedArray))
182-
// ;
183-
//
184-
// $this->assertEquals($expectedArray, $api->addComment(1, 2, array('body' => 'A new comment')));
185-
// $this->assertEquals($expectedArray, $api->addComment(1, 2, 'A new comment'));
186-
// }
187-
//
188-
// /**
189-
// * @test
190-
// */
191-
// public function shouldUpdateComment()
192-
// {
193-
// $expectedArray = array('id' => 3, 'body' => 'An edited comment');
194-
//
195-
// $api = $this->getApiMock();
196-
// $api->expects($this->once())
197-
// ->method('put')
198-
// ->with('projects/1/issues/2/notes/3', array('body' => 'An edited comment'))
199-
// ->will($this->returnValue($expectedArray))
200-
// ;
201-
//
202-
// $this->assertEquals($expectedArray, $api->updateComment(1, 2, 3, 'An edited comment'));
203-
// }
93+
/**
94+
* @test
95+
*/
96+
public function shouldGetAllLists()
97+
{
98+
$expectedArray = array(
99+
array(
100+
'id' => 1,
101+
'label' => array(
102+
'name' => 'First label',
103+
'color' => '#F0AD4E',
104+
'description' => null
105+
),
106+
'position' => 1
107+
), array(
108+
'id' => 2,
109+
'label' => array(
110+
'name' => 'Second label',
111+
'color' => '#F0AD4E',
112+
'description' => null
113+
),
114+
'position' => 2
115+
)
116+
);
117+
118+
$api = $this->getApiMock();
119+
$api->expects($this->once())
120+
->method('get')
121+
->with('projects/1/boards/2/lists')
122+
->will($this->returnValue($expectedArray))
123+
;
124+
125+
$this->assertEquals($expectedArray, $api->allLists(1, 2));
126+
}
127+
128+
/**
129+
* @test
130+
*/
131+
public function shouldGetList()
132+
{
133+
$expectedArray = array(
134+
array(
135+
'id' => 3,
136+
'label' => array(
137+
'name' => 'Some label',
138+
'color' => '#F0AD4E',
139+
'description' => null
140+
),
141+
'position' => 3
142+
)
143+
);
144+
145+
$api = $this->getApiMock();
146+
$api->expects($this->once())
147+
->method('get')
148+
->with('projects/1/boards/2/lists/3')
149+
->will($this->returnValue($expectedArray))
150+
;
151+
152+
$this->assertEquals($expectedArray, $api->showList(1, 2, 3));
153+
}
154+
155+
/**
156+
* @test
157+
*/
158+
public function shouldCreateList()
159+
{
160+
$expectedArray = array(
161+
array(
162+
'id' => 3,
163+
'label' => array(
164+
'name' => 'Some label',
165+
'color' => '#F0AD4E',
166+
'description' => null
167+
),
168+
'position' => 3
169+
)
170+
);
171+
172+
$api = $this->getApiMock();
173+
$api->expects($this->once())
174+
->method('post')
175+
->with('projects/1/boards/2/lists', array('label_id' => 4))
176+
->will($this->returnValue($expectedArray))
177+
;
178+
179+
$this->assertEquals($expectedArray, $api->createList(1, 2, 4));
180+
}
181+
182+
/**
183+
* @test
184+
*/
185+
public function shouldUpdateList()
186+
{
187+
$expectedArray = array(
188+
array(
189+
'id' => 3,
190+
'label' => array(
191+
'name' => 'Some label',
192+
'color' => '#F0AD4E',
193+
'description' => null
194+
),
195+
'position' => 1
196+
)
197+
);
198+
199+
$api = $this->getApiMock();
200+
$api->expects($this->once())
201+
->method('put')
202+
->with('projects/5/boards/2/lists/3', array('position' => 1))
203+
->will($this->returnValue($expectedArray))
204+
;
205+
206+
$this->assertEquals($expectedArray, $api->updateList(5, 2, 3, 1));
207+
}
208+
209+
/**
210+
* @test
211+
*/
212+
public function shouldDeleteList()
213+
{
214+
$expectedBool = true;
215+
216+
$api = $this->getApiMock();
217+
$api->expects($this->once())
218+
->method('delete')
219+
->with('projects/1/boards/2/lists/3')
220+
->will($this->returnValue($expectedBool))
221+
;
222+
223+
$this->assertEquals($expectedBool, $api->deleteList(1, 2, 3));
224+
}
204225

205226
protected function getApiClass()
206227
{

0 commit comments

Comments
 (0)