Skip to content

Commit 47c3468

Browse files
committed
Add tests for build
1 parent 3d46851 commit 47c3468

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function remove($project_id)
135135
public function builds($project_id, $scope = null)
136136
{
137137
return $this->get($this->getProjectPath($project_id, 'builds'), array(
138-
'scope' => (array) $scope,
138+
'scope' => $scope
139139
));
140140
}
141141

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,65 @@ public function shouldRemoveProject()
179179
$this->assertEquals($expectedBool, $api->remove(1));
180180
}
181181

182+
/**
183+
* @test
184+
*/
185+
public function shouldGetBuilds()
186+
{
187+
$expectedArray = array(
188+
array('id' => 1, 'status' => 'success'),
189+
array('id' => 2, 'status' => 'failed')
190+
);
191+
192+
$api = $this->getApiMock();
193+
$api->expects($this->once())
194+
->method('get')
195+
->with('projects/1/builds')
196+
->will($this->returnValue($expectedArray))
197+
;
198+
199+
$this->assertEquals($expectedArray, $api->builds(1));
200+
}
201+
202+
/**
203+
* @test
204+
*/
205+
public function shouldGetBuildsWithScope()
206+
{
207+
$expectedArray = array(
208+
array('id' => 1, 'status' => 'success'),
209+
);
210+
211+
$api = $this->getApiMock();
212+
$api->expects($this->once())
213+
->method('get')
214+
->with('projects/1/builds', array('scope' => 'success'))
215+
->will($this->returnValue($expectedArray))
216+
;
217+
218+
$this->assertEquals($expectedArray, $api->builds(1, 'success'));
219+
}
220+
221+
/**
222+
* @test
223+
*/
224+
public function shouldGetBuildsWithMultipleScopes()
225+
{
226+
$expectedArray = array(
227+
array('id' => 1, 'status' => 'success'),
228+
array('id' => 1, 'status' => 'failed'),
229+
);
230+
231+
$api = $this->getApiMock();
232+
$api->expects($this->once())
233+
->method('get')
234+
->with('projects/1/builds', array('scope' => ['success', 'failed']))
235+
->will($this->returnValue($expectedArray))
236+
;
237+
238+
$this->assertEquals($expectedArray, $api->builds(1, ['success', 'failed']));
239+
}
240+
182241
/**
183242
* @test
184243
*/

0 commit comments

Comments
 (0)