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
4 changes: 3 additions & 1 deletion lib/Github/Api/Repository/DeployKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public function update($username, $repository, $id, array $params)
throw new MissingArgumentException(['title', 'key']);
}

return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys/'.rawurlencode($id), $params);
$this->remove($username, $repository, $id);

return $this->create($username, $repository, $params);
}

public function remove($username, $repository, $id)
Expand Down
16 changes: 12 additions & 4 deletions test/Github/Tests/Api/Repository/DeployKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public function shouldNotUpdateDeployKeyWithoutTitle()

$api = $this->getApiMock();
$api->expects($this->never())
->method('patch');
->method('delete');
$api->expects($this->never())
->method('post');

$api->update('KnpLabs', 'php-github-api', 123, $data);
}
Expand All @@ -126,7 +128,9 @@ public function shouldNotUpdateDeployKeyWithoutKey()

$api = $this->getApiMock();
$api->expects($this->never())
->method('patch');
->method('delete');
$api->expects($this->never())
->method('post');

$api->update('KnpLabs', 'php-github-api', 123, $data);
}
Expand All @@ -141,8 +145,12 @@ public function shouldUpdateDeployKey()

$api = $this->getApiMock();
$api->expects($this->once())
->method('patch')
->with('/repos/KnpLabs/php-github-api/keys/123', $data)
->method('delete')
->with('/repos/KnpLabs/php-github-api/keys/123')
->will($this->returnValue($expectedValue));
$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/keys', $data)
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data));
Expand Down