Skip to content
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
14 changes: 14 additions & 0 deletions lib/Github/Api/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ public function update($username, $repository, array $values)
return $this->patch('repos/'.urlencode($username).'/'.urlencode($repository), $values);
}

/**
* Delete a repository
* @link http://developer.github.com/v3/repos/
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
*
* @return mixed null on success, arrray on error with 'message'
*/
public function delete($username, $repository)
{
return parent::delete('repos/'.urlencode($username).'/'.urlencode($repository));
}

/**
* Manage the collaborators of a repository
* @link http://developer.github.com/v3/repos/collaborators/
Expand Down
29 changes: 29 additions & 0 deletions test/Github/Tests/Api/RepoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,36 @@ public function shouldUpdate()

$this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', array('description' => 'test', 'homepage' => 'http://l3l0.eu')));
}

/**
* @test
*/
public function shouldDelete()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('delete')
->with('l3l0Repo', 'test')
->will($this->returnValue(null));

$this->assertNull($api->delete('l3l0Repo', 'test'));
}

/**
* @test
*/
public function shouldNotDelete()
{
$expectedArray = array('message'=>'Not Found');

$api = $this->getApiMock();
$api->expects($this->once())
->method('delete')
->with('l3l0Repo', 'uknown-repo')
->will($this->returnValue(array('message'=>'Not Found')));

$this->assertEquals($expectedArray, $api->delete('l3l0Repo', 'uknown-repo'));
}
/**
* @test
*/
Expand Down