Skip to content

Commit 44a6eb0

Browse files
authored
Merge pull request #130 from benmag/master
Add build and trace to Project API
2 parents aefeb94 + 06e8922 commit 44a6eb0

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ public function builds($project_id, $scope = null)
139139
));
140140
}
141141

142+
/**
143+
* @param $project_id
144+
* @param $build_id
145+
* @return mixed
146+
*/
147+
public function build($project_id, $build_id)
148+
{
149+
return $this->get($this->getProjectPath($project_id, 'builds/'.$this->encodePath($build_id)));
150+
}
151+
152+
/**
153+
* @param $project_id
154+
* @param $build_id
155+
* @return mixed
156+
*/
157+
public function trace($project_id, $build_id)
158+
{
159+
return $this->get($this->getProjectPath($project_id, 'builds/'.$this->encodePath($build_id).'/trace'));
160+
}
161+
142162
/**
143163
* @param int $project_id
144164
* @param string $username_query

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,40 @@ public function shouldGetBuildsWithMultipleScopes()
238238
$this->assertEquals($expectedArray, $api->builds(1, array('success', 'failed')));
239239
}
240240

241+
/**
242+
* @test
243+
*/
244+
public function shouldGetBuild()
245+
{
246+
$expectedArray = array('id' => 2);
247+
248+
$api = $this->getApiMock();
249+
$api->expects($this->once())
250+
->method('get')
251+
->with('projects/1/builds/2')
252+
->will($this->returnValue($expectedArray))
253+
;
254+
255+
$this->assertEquals($expectedArray, $api->build(1, 2));
256+
}
257+
258+
/**
259+
* @test
260+
*/
261+
public function shouldGetTrace()
262+
{
263+
$expectedString = 'runner trace of a specific build';
264+
265+
$api = $this->getApiMock();
266+
$api->expects($this->once())
267+
->method('get')
268+
->with('projects/1/builds/2/trace')
269+
->will($this->returnValue($expectedString))
270+
;
271+
272+
$this->assertEquals($expectedString, $api->trace(1, 2));
273+
}
274+
241275
/**
242276
* @test
243277
*/

0 commit comments

Comments
 (0)