Skip to content

Add Deployment show method #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/repo/deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ You can also filter the returned results (see [the documentation](https://develo
$deployments = $client->api('deployment')->all('KnpLabs', 'php-github-api', array('environment' => 'production'));
```

### List one deployment.

```php
$deployment = $client->api('deployment')->show('KnpLabs', 'php-github-api', $id);
```

#### Create a new deployments.

The `ref` parameter is required.
Expand Down
14 changes: 14 additions & 0 deletions lib/Github/Api/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ public function all($username, $repository, array $params = array())
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params);
}

/**
* Get a deployment in selected repository.
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
* @param int $id the id of the deployment
*
* @return array
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id));
}

/**
* Create a new deployment for the given username and repo.
* @link https://developer.github.com/v3/repos/deployments/#create-a-deployment
Expand Down
16 changes: 16 additions & 0 deletions test/Github/Tests/Api/DeploymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public function shouldGetAllDeploymentsWithFilterParameters()
$api->all('KnpLabs', 'php-github-api', $filterData);
}

/**
* @test
*/
public function shouldShowProject()
{
$expectedValue = array('id' => 123, 'ref' => 'master');

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/deployments/123')
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123));
}

/**
* @test
*/
Expand Down