Skip to content

Commit f31725f

Browse files
committed
Added support for updating a label
1 parent 4b8a05a commit f31725f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/Github/Api/Issue/Labels.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ public function deleteLabel($username, $repository, $label)
3838
return $this->delete('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label));
3939
}
4040

41+
public function update($username, $repository, $label, $newName, $color)
42+
{
43+
$params = array(
44+
'name' => $newName,
45+
'color' => $color,
46+
);
47+
48+
return $this->patch('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params);
49+
}
50+
4151
public function add($username, $repository, $issue, $labels)
4252
{
4353
if (is_string($labels)) {

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ public function shouldDeleteLabel()
9191
$this->assertEquals($expectedValue, $api->deleteLabel('KnpLabs', 'php-github-api', 'foo'));
9292
}
9393

94+
/**
95+
* @test
96+
*/
97+
public function shouldUpdateLabel()
98+
{
99+
$expectedValue = array(array('name' => 'bar', 'color' => 'FFF'));
100+
$data = array('name' => 'bar', 'color' => 'FFF');
101+
102+
$api = $this->getApiMock();
103+
$api->expects($this->once())
104+
->method('patch')
105+
->with('repos/KnpLabs/php-github-api/labels/foo', $data)
106+
->will($this->returnValue($expectedValue));
107+
108+
$this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'foo', 'bar', 'FFF'));
109+
}
110+
94111
/**
95112
* @test
96113
*/

0 commit comments

Comments
 (0)