@@ -46,43 +46,50 @@ public function testGetSingleComment()
4646 public function testCreateCommentSuccess ()
4747 {
4848 $ endpoint = 'repositories/gentle/eof/pullrequests/1/comments ' ;
49- $ params = array (
50- 'content ' => 'dummy comment '
51- );
49+ $ expectedResult = $ this ->fakeResponse (array ('dummy ' ));
5250
53- $ comment = $ this ->getApiMock ('Bitbucket\API\Repositories\PullRequests\Comments ' );
54- $ comment ->expects ($ this ->once ())
55- ->method ('requestPost ' )
56- ->with ($ endpoint , $ params );
51+ $ client = $ this ->getHttpClientMock ();
52+ $ client ->expects ($ this ->once ())
53+ ->method ('post ' )
54+ ->with ($ endpoint )
55+ ->will ($ this ->returnValue ($ expectedResult ));
5756
58- /** @var $comment \Bitbucket\API\Repositories\PullRequests\Comments */
59- $ comment ->create ('gentle ' , 'eof ' , 1 , 'dummy comment ' );
57+ /** @var \Bitbucket\API\Repositories\PullRequests\Comments $comments */
58+ $ comments = $ this ->getClassMock ('Bitbucket\API\Repositories\PullRequests\Comments ' , $ client );
59+ $ actual = $ comments ->create ('gentle ' , 'eof ' , 1 , 'test ' );
60+
61+ $ this ->assertEquals ($ expectedResult , $ actual );
6062 }
6163
6264 public function testUpdateCommentSuccess ()
6365 {
6466 $ endpoint = 'repositories/gentle/eof/pullrequests/1/comments/3 ' ;
65- $ params = array ('content ' => 'dummy ' );
67+ $ expectedResult = array ('content ' => 'dummy ' );
68+
69+ $ client = $ this ->getHttpClientMock ();
70+ $ client ->expects ($ this ->once ())
71+ ->method ('put ' )
72+ ->with ($ endpoint )
73+ ->will ($ this ->returnValue ($ expectedResult ));
6674
67- $ comment = $ this ->getApiMock ('Bitbucket\API\Repositories\PullRequests\Comments ' );
68- $ comment ->expects ($ this ->once ())
69- ->method ('requestPut ' )
70- ->with ($ endpoint , $ params );
75+ /** @var \Bitbucket\API\Repositories\PullRequests\Comments $comments */
76+ $ comments = $ this ->getClassMock ('Bitbucket\API\Repositories\PullRequests\Comments ' , $ client );
77+ $ actual = $ comments ->update ('gentle ' , 'eof ' , 1 , 3 , 'dummy ' );
7178
72- /** @var $comment \Bitbucket\API\Repositories\PullRequests\Comments */
73- $ comment ->update ('gentle ' , 'eof ' , 1 , 3 , 'dummy ' );
79+ $ this ->assertEquals ($ expectedResult , $ actual );
7480 }
7581
7682 public function testDeleteCommentSuccess ()
7783 {
78- $ endpoint = 'repositories/gentle/eof/pullrequests/1/comments/2 ' ;
84+ $ endpoint = 'repositories/gentle/eof/pullrequests/1/comments/2 ' ;
7985
80- $ comment = $ this ->getApiMock ( ' Bitbucket\API\Repositories\PullRequests\Comments ' );
81- $ comment ->expects ($ this ->once ())
82- ->method ('requestDelete ' )
86+ $ client = $ this ->getHttpClientMock ( );
87+ $ client ->expects ($ this ->once ())
88+ ->method ('delete ' )
8389 ->with ($ endpoint );
8490
85- /** @var $comment \Bitbucket\API\Repositories\PullRequests\Comments */
86- $ comment ->delete ('gentle ' , 'eof ' , 1 , 2 );
91+ /** @var \Bitbucket\API\Repositories\PullRequests\Comments $comments */
92+ $ comments = $ this ->getClassMock ('Bitbucket\API\Repositories\PullRequests\Comments ' , $ client );
93+ $ comments ->delete ('gentle ' , 'eof ' , 1 , 2 );
8794 }
8895}
0 commit comments