@@ -46,43 +46,50 @@ public function testGetSingleComment()
46
46
public function testCreateCommentSuccess ()
47
47
{
48
48
$ endpoint = 'repositories/gentle/eof/pullrequests/1/comments ' ;
49
- $ params = array (
50
- 'content ' => 'dummy comment '
51
- );
49
+ $ expectedResult = $ this ->fakeResponse (array ('dummy ' ));
52
50
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 ));
57
56
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 );
60
62
}
61
63
62
64
public function testUpdateCommentSuccess ()
63
65
{
64
66
$ 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 ));
66
74
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 ' );
71
78
72
- /** @var $comment \Bitbucket\API\Repositories\PullRequests\Comments */
73
- $ comment ->update ('gentle ' , 'eof ' , 1 , 3 , 'dummy ' );
79
+ $ this ->assertEquals ($ expectedResult , $ actual );
74
80
}
75
81
76
82
public function testDeleteCommentSuccess ()
77
83
{
78
- $ endpoint = 'repositories/gentle/eof/pullrequests/1/comments/2 ' ;
84
+ $ endpoint = 'repositories/gentle/eof/pullrequests/1/comments/2 ' ;
79
85
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 ' )
83
89
->with ($ endpoint );
84
90
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 );
87
94
}
88
95
}
0 commit comments