Skip to content

Commit 0a483df

Browse files
committed
tests: update error message for PHP 8.6
1 parent 33846f7 commit 0a483df

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

tests/Unit/Api/AbstractApi/GetTest.php

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testGetWithHttpClient(): void
4949
* @dataProvider getJsonDecodingFromGetMethodData
5050
*/
5151
#[DataProvider('getJsonDecodingFromGetMethodData')]
52-
public function testJsonDecodingFromGetMethod(string $response, ?bool $decode, $expected): void
52+
public function testJsonDecodingFromGetMethod(string $response, ?bool $shouldDecode, $expected): void
5353
{
5454
$client = $this->createStub(Client::class);
5555
$client->method('getLastResponseBody')->willReturn($response);
@@ -63,8 +63,8 @@ public function testJsonDecodingFromGetMethod(string $response, ?bool $decode, $
6363
}
6464

6565
// Perform the tests
66-
if (is_bool($decode)) {
67-
$this->assertSame($expected, $method->invoke($api, 'path', $decode));
66+
if (is_bool($shouldDecode)) {
67+
$this->assertSame($expected, $method->invoke($api, 'path', $shouldDecode));
6868
} else {
6969
$this->assertSame($expected, $method->invoke($api, 'path'));
7070
}
@@ -73,12 +73,36 @@ public function testJsonDecodingFromGetMethod(string $response, ?bool $decode, $
7373
public static function getJsonDecodingFromGetMethodData(): array
7474
{
7575
return [
76-
'test decode by default' => ['{"foo_bar": 12345}', null, ['foo_bar' => 12345]],
77-
'test decode by default, JSON decode: false' => ['{"foo_bar": 12345}', false, '{"foo_bar": 12345}'],
78-
'test decode by default, JSON decode: true' => ['{"foo_bar": 12345}', true, ['foo_bar' => 12345]],
79-
'Empty body, JSON decode: false' => ['', false, false],
80-
'Empty body, JSON decode: true' => ['', true, false],
81-
'test invalid JSON' => ['{"foo_bar":', true, 'Error decoding body as JSON: Syntax error'],
76+
'test decode by default' => [
77+
'{"foo_bar": 12345}',
78+
null,
79+
['foo_bar' => 12345],
80+
],
81+
'test decode by default, JSON decode: false' => [
82+
'{"foo_bar": 12345}',
83+
false,
84+
'{"foo_bar": 12345}',
85+
],
86+
'test decode by default, JSON decode: true' => [
87+
'{"foo_bar": 12345}',
88+
true,
89+
['foo_bar' => 12345],
90+
],
91+
'Empty body, JSON decode: false' => [
92+
'',
93+
false,
94+
false,
95+
],
96+
'Empty body, JSON decode: true' => [
97+
'',
98+
true,
99+
false,
100+
],
101+
'test invalid JSON' => [
102+
'{"foo_bar":',
103+
true,
104+
(PHP_VERSION_ID < 80600) ? 'Error decoding body as JSON: Syntax error' : 'Error decoding body as JSON: Syntax error near location 1:12',
105+
],
82106
];
83107
}
84108

0 commit comments

Comments
 (0)