Skip to content

Commit ca00bb6

Browse files
Copilotovertrue
andcommitted
Fix CI test errors: correct mock setup for ResponseInterface.getBody() method
Co-authored-by: overtrue <[email protected]>
1 parent b61204f commit ca00bb6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/OAuthTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ public function test_it_can_get_token()
7777
];
7878
$provider = new OAuthTestProviderStub($config);
7979
$response = m::mock(\Psr\Http\Message\ResponseInterface::class);
80+
$stream = m::mock(\Psr\Http\Message\StreamInterface::class);
8081

81-
$response->shouldReceive('getBody')->andReturn($response);
82-
$response->shouldReceive('__toString')->andReturn(\json_encode([
82+
$stream->shouldReceive('__toString')->andReturn(\json_encode([
8383
'access_token' => 'fake_access_token',
8484
'refresh_token' => 'fake_refresh_token',
8585
'expires_in' => 123456,
8686
]));
87+
$response->shouldReceive('getBody')->andReturn($stream);
8788

8889
$provider->getHttpClient()->shouldReceive('post')->with('http://token.url', [
8990
'form_params' => [
@@ -128,12 +129,14 @@ public function test_it_can_get_user_by_code()
128129
$provider = new OAuthTestProviderStub($config);
129130

130131
$response = m::mock(\Psr\Http\Message\ResponseInterface::class);
131-
$response->shouldReceive('getBody')->andReturn($response);
132-
$response->shouldReceive('__toString')->andReturn(\json_encode([
132+
$stream = m::mock(\Psr\Http\Message\StreamInterface::class);
133+
134+
$stream->shouldReceive('__toString')->andReturn(\json_encode([
133135
'access_token' => 'fake_access_token',
134136
'refresh_token' => 'fake_refresh_token',
135137
'expires_in' => 123456,
136138
]));
139+
$response->shouldReceive('getBody')->andReturn($stream);
137140

138141
$provider->getHttpClient()->shouldReceive('post')->with('http://token.url', [
139142
'form_params' => [

0 commit comments

Comments
 (0)