Skip to content

Commit c7b720e

Browse files
[11.8] Implement Projects::pipelineJobs() (GitLabPHP#686)
* Add pipelineJobs method in Projects.php and extend ProjectsTest * Update ProjectsTest.php Co-authored-by: Graham Campbell <[email protected]>
1 parent a271c6f commit c7b720e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Api/Projects.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,17 @@ public function pipeline($project_id, int $pipeline_id)
396396
return $this->get($this->getProjectPath($project_id, 'pipelines/'.self::encodePath($pipeline_id)));
397397
}
398398

399+
/**
400+
* @param int|string $project_id
401+
* @param int $pipeline_id
402+
*
403+
* @return mixed
404+
*/
405+
public function pipelineJobs($project_id, int $pipeline_id)
406+
{
407+
return $this->get($this->getProjectPath($project_id, 'pipelines/'.self::encodePath($pipeline_id).'/jobs'));
408+
}
409+
399410
/**
400411
* @param int|string $project_id
401412
* @param int $pipeline_id

tests/Api/ProjectsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,26 @@ public function shouldGetPipeline(): void
808808
$this->assertEquals($expectedArray, $api->pipeline(1, 3));
809809
}
810810

811+
/**
812+
* @test
813+
*/
814+
public function shouldGetPipelineJobs(): void
815+
{
816+
$expectedArray = [
817+
['id' => 1, 'status' => 'success', 'stage' => 'Build'],
818+
['id' => 2, 'status' => 'failed', 'stage' => 'Build'],
819+
['id' => 3, 'status' => 'pending', 'stage' => 'Build'],
820+
];
821+
822+
$api = $this->getApiMock();
823+
$api->expects($this->once())
824+
->method('get')
825+
->with('projects/1/pipelines/3/jobs')
826+
->will($this->returnValue($expectedArray));
827+
828+
$this->assertEquals($expectedArray, $api->pipelineJobs(1, 3));
829+
}
830+
811831
/**
812832
* @test
813833
*/

0 commit comments

Comments
 (0)