Skip to content

Commit

Permalink
Merge pull request #240 from fbourigault/deprecate-comments
Browse files Browse the repository at this point in the history
Deprecate merge request comment related methods
  • Loading branch information
fbourigault authored Aug 28, 2017
2 parents af99282 + 6ae9c05 commit 84fbf5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 41 deletions.
10 changes: 6 additions & 4 deletions lib/Gitlab/Api/MergeRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ public function addNote($project_id, $mr_id, $note)
*/
public function showComments($project_id, $mr_id)
{
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/comments'));
@trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED);

return $this->showNotes($project_id, $mr_id);
}

/**
Expand All @@ -173,9 +175,9 @@ public function showComments($project_id, $mr_id)
*/
public function addComment($project_id, $mr_id, $note)
{
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/comments'), array(
'note' => $note
));
@trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED);

return $this->addNote($project_id, $mr_id, $note);
}

/**
Expand Down
37 changes: 0 additions & 37 deletions test/Gitlab/Tests/Api/MergeRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,43 +163,6 @@ public function shouldGetMergeRequestNotes()
$this->assertEquals($expectedArray, $api->showNotes(1, 2));
}

/**
* @test
*/
public function shouldGetMergeRequestComments()
{
$expectedArray = array(
array('id' => 1, 'note' => 'A comment'),
array('id' => 2, 'note' => 'Another comment')
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('projects/1/merge_requests/2/comments')
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->showComments(1, 2));
}

/**
* @test
*/
public function shouldAddMergeRequestComment()
{
$expectedArray = array('id' => 2, 'title' => 'A comment');

$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('projects/1/merge_requests/2/comments', array('note' => 'A comment'))
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->addComment(1, 2, 'A comment'));
}

/**
* @test
*/
Expand Down

0 comments on commit 84fbf5d

Please sign in to comment.