Make ExtensionJsonTestBase more extendable

Extensions or skins might want to define their own tests and not
giving them access to the cached JSON is limiting. Because the
method was private for a reason, make it final to prevent overriding
it and breaking things in weird ways.

Also, now that we are on PHP 7.4, use JSON_THROW_ON_ERROR to allow
PHPUnit to have clearer error messages when extension.json/skin.json
is not valid JSON.

Follows-Up: I47757958e54d5e9d47a309b4037ff47dd9c1d382
Change-Id: I5819da9c59499d1752057f79b1855872064ff32e
This commit is contained in:
mainframe98 2023-03-28 20:32:45 +02:00
parent 5c573b3e3a
commit ffed58bcef

View file

@ -71,12 +71,14 @@ abstract class ExtensionJsonTestBase extends MediaWikiIntegrationTestCase {
$this->disallowHttpAccess();
}
private function getExtensionJson(): array {
final protected function getExtensionJson(): array {
static $extensionJson = null;
if ( $extensionJson === null ) {
$extensionJson = json_decode(
file_get_contents( $this->extensionJsonPath ),
true
true,
512,
JSON_THROW_ON_ERROR
);
}
return $extensionJson;