Skip to content

Commit 8c5616c

Browse files
committed
remove incorrect MissingArgumentException, add docs, update tests
1 parent 94dec1e commit 8c5616c

File tree

4 files changed

+51
-36
lines changed

4 files changed

+51
-36
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ v3 APIs:
4949
* [Checks](repo/checks.md)
5050
* [Contents](repo/contents.md)
5151
* [Deployments](repo/deployments.md)
52+
* [Labels](repo/labels.md)
5253
* [Protection](repo/protection.md)
5354
* [Releases](repo/releases.md)
5455
* [Assets](repo/assets.md)

doc/repo/labels.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Repo / Labels API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
### List all labels for this repository
5+
6+
```php
7+
$labels = $client->api('repo')->labels()->all('twbs', 'bootstrap');
8+
```
9+
10+
### Get a single label
11+
12+
```php
13+
$label = $client->api('repo')->labels()->show('twbs', 'bootstrap', 'feature');
14+
```
15+
16+
### Create a label
17+
18+
> Requires [authentication](../security.md).
19+
20+
```php
21+
$params = [
22+
'name' => 'bug',
23+
'color' => 'f29513',
24+
'description' => 'Something isn\'t working',
25+
];
26+
$label = $client->api('repo')->labels()->create('twbs', 'bootstrap', $params);
27+
```
28+
29+
### Update a label
30+
31+
> Requires [authentication](../security.md).
32+
33+
```php
34+
$params = [
35+
'new_name' => 'bug :bug:',
36+
'color' => 'b01f26',
37+
'description' => 'Small bug fix required',
38+
];
39+
$label = $client->api('repo')->labels()->update('twbs', 'bootstrap', 'bug', $params);
40+
```
41+
42+
### Delete a label
43+
44+
> Requires [authentication](../security.md).
45+
46+
```php
47+
$label = $client->api('repo')->labels()->remove('twbs', 'bootstrap', 'bug');
48+
```

lib/Github/Api/Repository/Labels.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ public function create($username, $repository, array $params)
3333

3434
public function update($username, $repository, $label, array $params)
3535
{
36-
if (!isset($params['name'], $params['color'])) {
37-
throw new MissingArgumentException(['name', 'color']);
38-
}
39-
4036
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params);
4137
}
4238

test/Github/Tests/Api/Repository/LabelsTest.php

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -102,43 +102,13 @@ public function shouldCreateLabel()
102102
$this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data));
103103
}
104104

105-
/**
106-
* @test
107-
*/
108-
public function shouldNotUpdateLabelWithoutName()
109-
{
110-
$this->expectException(MissingArgumentException::class);
111-
$data = ['color' => 'red'];
112-
113-
$api = $this->getApiMock();
114-
$api->expects($this->never())
115-
->method('patch');
116-
117-
$api->update('KnpLabs', 'php-github-api', 'labelName', $data);
118-
}
119-
120-
/**
121-
* @test
122-
*/
123-
public function shouldNotUpdateLabelWithoutColor()
124-
{
125-
$this->expectException(MissingArgumentException::class);
126-
$data = ['name' => 'test'];
127-
128-
$api = $this->getApiMock();
129-
$api->expects($this->never())
130-
->method('patch');
131-
132-
$api->update('KnpLabs', 'php-github-api', 'labelName', $data);
133-
}
134-
135105
/**
136106
* @test
137107
*/
138108
public function shouldUpdateLabel()
139109
{
140-
$expectedValue = ['label' => 'somename'];
141-
$data = ['name' => 'test', 'color' => 'red'];
110+
$expectedValue = ['name' => 'test'];
111+
$data = ['new_name' => 'test', 'color' => 'red'];
142112

143113
$api = $this->getApiMock();
144114
$api->expects($this->once())

0 commit comments

Comments
 (0)