Skip to content

Commit 496b082

Browse files
authored
Merge pull request KnpLabs#463 from styxit/show-deployment
Add Deployment show method
2 parents 069829f + d7d7307 commit 496b082

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

doc/repo/deployments.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ You can also filter the returned results (see [the documentation](https://develo
1515
$deployments = $client->api('deployment')->all('KnpLabs', 'php-github-api', array('environment' => 'production'));
1616
```
1717

18+
### List one deployment.
19+
20+
```php
21+
$deployment = $client->api('deployment')->show('KnpLabs', 'php-github-api', $id);
22+
```
23+
1824
#### Create a new deployments.
1925

2026
The `ref` parameter is required.

lib/Github/Api/Deployment.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ public function all($username, $repository, array $params = array())
2525
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params);
2626
}
2727

28+
/**
29+
* Get a deployment in selected repository.
30+
*
31+
* @param string $username the user who owns the repo
32+
* @param string $repository the name of the repo
33+
* @param int $id the id of the deployment
34+
*
35+
* @return array
36+
*/
37+
public function show($username, $repository, $id)
38+
{
39+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id));
40+
}
41+
2842
/**
2943
* Create a new deployment for the given username and repo.
3044
* @link https://developer.github.com/v3/repos/deployments/#create-a-deployment

test/Github/Tests/Api/DeploymentTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ public function shouldGetAllDeploymentsWithFilterParameters()
4646
$api->all('KnpLabs', 'php-github-api', $filterData);
4747
}
4848

49+
/**
50+
* @test
51+
*/
52+
public function shouldShowProject()
53+
{
54+
$expectedValue = array('id' => 123, 'ref' => 'master');
55+
56+
$api = $this->getApiMock();
57+
$api->expects($this->once())
58+
->method('get')
59+
->with('/repos/KnpLabs/php-github-api/deployments/123')
60+
->will($this->returnValue($expectedValue));
61+
62+
$this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
63+
}
64+
4965
/**
5066
* @test
5167
*/

0 commit comments

Comments
 (0)