Skip to content

Commit 8714998

Browse files
committed
[Test] Use mocked HTTP client in testGetAccessTokenFail
At first, only me and God knew why HTTP client used by OAuth2Listener in OAuth2ListenerTest:testGetAccessTokenFail was not mocked. Now, only God knows...
1 parent 84e98bc commit 8714998

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/Bitbucket/Tests/API/Http/Listener/OAuth2ListenerTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,30 @@ public function testGetAccessTokenShouldFailWithInvalidJson()
5151
*/
5252
public function testGetAccessTokenFail()
5353
{
54+
$response = new Response();
55+
$response->setContent('{"error_description": "Invalid OAuth client credentials", "error": "unauthorized_client"}');
56+
5457
$oauth_params = array(
5558
'client_id' => 'aaa',
5659
'client_secret' => 'bbb'
5760
);
5861

62+
$httpClient = $this->getHttpClientMock();
63+
$httpClient->expects($this->any())
64+
->method('POST')
65+
->with(OAuth2Listener::ENDPOINT_ACCESS_TOKEN,
66+
array(
67+
'grant_type' => 'client_credentials',
68+
'client_id' => $oauth_params['client_id'],
69+
'client_secret' => $oauth_params['client_secret'],
70+
'scope' => ''
71+
))
72+
->will($this->returnValue($response))
73+
;
74+
5975
$repositories = new Repositories(array(), $this->getHttpClient());
6076
$repositories->getClient()->addListener(
61-
new OAuth2Listener($oauth_params)
77+
new OAuth2Listener($oauth_params, $httpClient)
6278
);
6379

6480
$repositories->all('my_account');

0 commit comments

Comments
 (0)