Skip to content

Commit b3244ef

Browse files
authored
[11.13] Addition of Status & Environment to list of possible values (#769)
* Addition of Status & Environment to list of possible values that can be sent to deployment * Fix style issue * Missed a space.. * Fix style issues * Missed something in the style * Update php doc with new additional values * Fix for style * update spaces * Missed something with the style * copy paste error
1 parent f56d415 commit b3244ef

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/Api/Deployments.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class Deployments extends AbstractApi
2323
* @var string $order_by Return deployments ordered by id, iid, created_at, updated_at,
2424
* or ref fields (default is id)
2525
* @var string $sort Return deployments sorted in asc or desc order (default is desc)
26+
* @var string $status Return deployments filtered by status of deployment allowed
27+
* values of status are 'created', 'running', 'success', 'failed',
28+
* 'canceled', 'blocked'
29+
* @var string $environment Return deployments filtered to a particular environment
2630
* }
2731
*
2832
* @return mixed
@@ -36,6 +40,11 @@ public function all($project_id, array $parameters = [])
3640
$resolver->setDefined('sort')
3741
->setAllowedTypes('sort', 'string')
3842
->setAllowedValues('sort', ['desc', 'asc']);
43+
$resolver->setDefined('status')
44+
->setAllowedTypes('status', 'string')
45+
->setAllowedValues('status', ['created', 'running', 'success', 'failed', 'canceled', 'blocked']);
46+
$resolver->setDefined('environment')
47+
->setAllowedTypes('environment', 'string');
3948

4049
return $this->get($this->getProjectPath($project_id, 'deployments'), $resolver->resolve($parameters));
4150
}

tests/Api/DeploymentsTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,59 @@ protected function getApiClass()
278278
{
279279
return Deployments::class;
280280
}
281+
282+
/**
283+
* @test
284+
*/
285+
public function shouldAllowDeploymentFilterByStatus(): void
286+
{
287+
$expectedArray = $this->getMultipleDeploymentsData();
288+
289+
$api = $this->getMultipleDeploymentsRequestMock(
290+
'projects/1/deployments',
291+
$expectedArray,
292+
['status' => 'success']
293+
);
294+
295+
$this->assertEquals(
296+
$expectedArray,
297+
$api->all(1, ['status' => 'success'])
298+
);
299+
}
300+
301+
/**
302+
* @test
303+
*/
304+
public function shouldAllowFilterByEnvironment(): void
305+
{
306+
$expectedArray = $this->getMultipleDeploymentsData();
307+
308+
$api = $this->getMultipleDeploymentsRequestMock(
309+
'projects/1/deployments',
310+
$expectedArray,
311+
['environment' => 'production']
312+
);
313+
314+
$this->assertEquals(
315+
$expectedArray,
316+
$api->all(1, ['environment' => 'production'])
317+
);
318+
}
319+
320+
/**
321+
* @test
322+
*/
323+
public function shouldAllowEmptyArrayIfAllExcludedByFilter(): void
324+
{
325+
$expectedArray = $this->getMultipleDeploymentsData();
326+
327+
$api = $this->getMultipleDeploymentsRequestMock(
328+
'projects/1/deployments',
329+
[],
330+
['environment' => 'test']
331+
);
332+
333+
$this->assertEquals([], $api->all(1, ['environment' => 'test'])
334+
);
335+
}
281336
}

0 commit comments

Comments
 (0)