Skip to content

Commit 3867a94

Browse files
committed
Merge pull request #10 from githalytics/master
Added delete support to the Github/Api/Repo
2 parents d6fae86 + 63e72c7 commit 3867a94

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

lib/Github/Api/Repo.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ public function update($username, $repository, array $values)
8686
return $this->patch('repos/'.urlencode($username).'/'.urlencode($repository), $values);
8787
}
8888

89+
/**
90+
* Delete a repository
91+
* @link http://developer.github.com/v3/repos/
92+
*
93+
* @param string $username the user who owns the repository
94+
* @param string $repository the name of the repository
95+
*
96+
* @return mixed null on success, arrray on error with 'message'
97+
*/
98+
public function delete($username, $repository)
99+
{
100+
return parent::delete('repos/'.urlencode($username).'/'.urlencode($repository));
101+
}
102+
89103
/**
90104
* Manage the collaborators of a repository
91105
* @link http://developer.github.com/v3/repos/collaborators/

test/Github/Tests/Api/RepoTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,36 @@ public function shouldUpdate()
269269

270270
$this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', array('description' => 'test', 'homepage' => 'http://l3l0.eu')));
271271
}
272+
273+
/**
274+
* @test
275+
*/
276+
public function shouldDelete()
277+
{
278+
$api = $this->getApiMock();
279+
$api->expects($this->once())
280+
->method('delete')
281+
->with('l3l0Repo', 'test')
282+
->will($this->returnValue(null));
283+
284+
$this->assertNull($api->delete('l3l0Repo', 'test'));
285+
}
272286

287+
/**
288+
* @test
289+
*/
290+
public function shouldNotDelete()
291+
{
292+
$expectedArray = array('message'=>'Not Found');
293+
294+
$api = $this->getApiMock();
295+
$api->expects($this->once())
296+
->method('delete')
297+
->with('l3l0Repo', 'uknown-repo')
298+
->will($this->returnValue(array('message'=>'Not Found')));
299+
300+
$this->assertEquals($expectedArray, $api->delete('l3l0Repo', 'uknown-repo'));
301+
}
273302
/**
274303
* @test
275304
*/

0 commit comments

Comments
 (0)