mirror of
https://github.com/yiisoft/yii2.git
synced 2026-02-20 00:32:19 +01:00
Fix #20715: Adjust JSON helper error message assertions for PHP 8.6 compatibility in JsonTest class
This commit is contained in:
@@ -5,6 +5,7 @@ Yii Framework 2 Change Log
|
||||
------------------------
|
||||
|
||||
- Bug #20705: Replace `$this` with `self` in generics in Psalm annotations (mspirkov)
|
||||
- Bug #20715: Adjust `JSON` helper error message assertions for `PHP 8.6` compatibility in `JsonTest` class (terabytesoftw)
|
||||
|
||||
|
||||
2.0.54 January 09, 2026
|
||||
|
||||
@@ -231,7 +231,17 @@ PHP
|
||||
$json = "{'a': '1'}";
|
||||
Json::decode($json);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->assertSame(Json::$jsonErrorMessages['JSON_ERROR_SYNTAX'], $e->getMessage());
|
||||
if (PHP_VERSION_ID >= 80600) {
|
||||
$this->assertStringContainsString(
|
||||
Json::$jsonErrorMessages['JSON_ERROR_SYNTAX'],
|
||||
$e->getMessage(),
|
||||
);
|
||||
} else {
|
||||
$this->assertSame(
|
||||
Json::$jsonErrorMessages['JSON_ERROR_SYNTAX'],
|
||||
$e->getMessage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// unsupported type since PHP 5.5
|
||||
@@ -241,10 +251,16 @@ PHP
|
||||
Json::encode($data);
|
||||
fclose($fp);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$this->assertSame(Json::$jsonErrorMessages['JSON_ERROR_UNSUPPORTED_TYPE'], $e->getMessage());
|
||||
if (PHP_VERSION_ID >= 80600) {
|
||||
$this->assertStringContainsString(
|
||||
Json::$jsonErrorMessages['JSON_ERROR_UNSUPPORTED_TYPE'],
|
||||
$e->getMessage(),
|
||||
);
|
||||
} else {
|
||||
$this->assertSame(Json::$jsonErrorMessages['JSON_ERROR_SYNTAX'], $e->getMessage());
|
||||
$this->assertSame(
|
||||
Json::$jsonErrorMessages['JSON_ERROR_UNSUPPORTED_TYPE'],
|
||||
$e->getMessage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user