Skip to content

Commit 08d7f8a

Browse files
committed
Fix invalid mock return type in test
Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
1 parent f54cca2 commit 08d7f8a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/lib/Controller/OpenProjectControllerTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use GuzzleHttp\Exception\ConnectException;
1414
use GuzzleHttp\Exception\RequestException;
1515
use GuzzleHttp\Exception\ServerException;
16+
use GuzzleHttp\Psr7\Utils;
1617
use OCA\OpenProject\Service\OpenProjectAPIService;
1718
use OCP\Http\Client\IResponse;
1819
use OCP\Http\Client\LocalServerException;
@@ -161,21 +162,22 @@ public function isValidOpenProjectInstanceExpectionDataProvider() {
161162
$requestMock = $this->getMockBuilder('\Psr\Http\Message\RequestInterface')->getMock();
162163
$privateInstance = $this->getMockBuilder('\Psr\Http\Message\ResponseInterface')->getMock();
163164
$privateInstance->method('getBody')->willReturn(
164-
'{"_type":"Error","errorIdentifier":"urn:openproject-org:api:v3:errors:Unauthenticated"}'
165+
Utils::streamFor('{"_type":"Error","errorIdentifier":"urn:openproject-org:api:v3:errors:Unauthenticated"}')
165166
);
166167
$notOP = $this->getMockBuilder('\Psr\Http\Message\ResponseInterface')->getMock();
167-
$notOP->method('getBody')->willReturn('Unauthenticated');
168+
$notOPResponseBody = 'Unauthenticated';
169+
$notOP->method('getBody')->willReturn(Utils::streamFor($notOPResponseBody));
168170
$notOP->method('getReasonPhrase')->willReturn('Unauthenticated');
169-
$notOP->method('getStatusCode')->willReturn('401');
171+
$notOP->method('getStatusCode')->willReturn(401);
170172
$notOPButJSON = $this->getMockBuilder('\Psr\Http\Message\ResponseInterface')->getMock();
171173
$notOPButJSON->method('getBody')->willReturn(
172-
'{"what":"Error","why":"Unauthenticated"}'
174+
Utils::streamFor('{"what":"Error","why":"Unauthenticated"}')
173175
);
174176
$notOPButJSON->method('getReasonPhrase')->willReturn('Unauthenticated');
175-
$notOPButJSON->method('getStatusCode')->willReturn('401');
177+
$notOPButJSON->method('getStatusCode')->willReturn(401);
176178
$otherResponseMock = $this->getMockBuilder('\Psr\Http\Message\ResponseInterface')->getMock();
177179
$otherResponseMock->method('getReasonPhrase')->willReturn('Internal Server Error');
178-
$otherResponseMock->method('getStatusCode')->willReturn('500');
180+
$otherResponseMock->method('getStatusCode')->willReturn(500);
179181
return [
180182
[
181183
new ConnectException('a connection problem', $requestMock),

0 commit comments

Comments
 (0)