Skip to content

Commit a1cbde4

Browse files
committed
Merge pull request #112 from Fixico/add-builds
Add builds to Project API.
2 parents 5e50619 + f7de518 commit a1cbde4

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ public function remove($project_id)
127127
return $this->delete('projects/'.$this->encodePath($project_id));
128128
}
129129

130+
/**
131+
* @param int $project_id
132+
* @param array $scope
133+
* @return mixed
134+
*/
135+
public function builds($project_id, $scope = null)
136+
{
137+
return $this->get($this->getProjectPath($project_id, 'builds'), array(
138+
'scope' => $scope
139+
));
140+
}
141+
130142
/**
131143
* @param int $project_id
132144
* @param string $username_query

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' => array('success', 'failed')))
235+
->will($this->returnValue($expectedArray))
236+
;
237+
238+
$this->assertEquals($expectedArray, $api->builds(1, array('success', 'failed')));
239+
}
240+
182241
/**
183242
* @test
184243
*/

0 commit comments

Comments
 (0)