2015-05-14 05:51:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-15 23:09:26 +00:00
|
|
|
* @covers VersionChecker
|
2015-05-14 05:51:55 +00:00
|
|
|
*/
|
2018-02-17 12:29:13 +00:00
|
|
|
class VersionCheckerTest extends PHPUnit\Framework\TestCase {
|
2017-12-29 23:22:37 +00:00
|
|
|
|
|
|
|
|
use MediaWikiCoversValidator;
|
2018-04-12 16:49:27 +00:00
|
|
|
use PHPUnit4And6Compat;
|
2017-12-29 23:22:37 +00:00
|
|
|
|
2015-05-14 05:51:55 +00:00
|
|
|
/**
|
2018-09-08 00:02:53 +00:00
|
|
|
* @dataProvider provideMediaWikiCheck
|
2015-05-14 05:51:55 +00:00
|
|
|
*/
|
2018-09-08 00:02:53 +00:00
|
|
|
public function testMediaWikiCheck( $coreVersion, $constraint, $expected ) {
|
|
|
|
|
$checker = new VersionChecker( $coreVersion, '7.0.0' );
|
2016-12-03 18:06:46 +00:00
|
|
|
$this->assertEquals( $expected, !(bool)$checker->checkArray( [
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'MediaWiki' => $constraint,
|
|
|
|
|
],
|
2018-06-15 15:51:22 +00:00
|
|
|
] ) );
|
2015-05-14 05:51:55 +00:00
|
|
|
}
|
|
|
|
|
|
2018-09-08 00:02:53 +00:00
|
|
|
public static function provideMediaWikiCheck() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2016-07-10 15:23:29 +00:00
|
|
|
// [ $wgVersion, constraint, expected ]
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '1.25alpha', '>= 1.26', false ],
|
|
|
|
|
[ '1.25.0', '>= 1.26', false ],
|
|
|
|
|
[ '1.26alpha', '>= 1.26', true ],
|
|
|
|
|
[ '1.26alpha', '>= 1.26.0', true ],
|
|
|
|
|
[ '1.26alpha', '>= 1.26.0-stable', false ],
|
|
|
|
|
[ '1.26.0', '>= 1.26.0-stable', true ],
|
|
|
|
|
[ '1.26.1', '>= 1.26.0-stable', true ],
|
|
|
|
|
[ '1.27.1', '>= 1.26.0-stable', true ],
|
|
|
|
|
[ '1.26alpha', '>= 1.26.1', false ],
|
|
|
|
|
[ '1.26alpha', '>= 1.26alpha', true ],
|
|
|
|
|
[ '1.26alpha', '>= 1.25', true ],
|
|
|
|
|
[ '1.26.0-alpha.14', '>= 1.26.0-alpha.15', false ],
|
|
|
|
|
[ '1.26.0-alpha.14', '>= 1.26.0-alpha.10', true ],
|
|
|
|
|
[ '1.26.1', '>= 1.26.2, <=1.26.0', false ],
|
|
|
|
|
[ '1.26.1', '^1.26.2', false ],
|
2015-05-14 05:51:55 +00:00
|
|
|
// Accept anything for un-parsable version strings
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '1.26mwf14', '== 1.25alpha', true ],
|
|
|
|
|
[ 'totallyinvalid', '== 1.0', true ],
|
|
|
|
|
];
|
2015-05-14 05:51:55 +00:00
|
|
|
}
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
|
2018-09-08 00:02:53 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider providePhpValidCheck
|
|
|
|
|
*/
|
|
|
|
|
public function testPhpValidCheck( $phpVersion, $constraint, $expected ) {
|
|
|
|
|
$checker = new VersionChecker( '1.0.0', $phpVersion );
|
|
|
|
|
$this->assertEquals( $expected, !(bool)$checker->checkArray( [
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'platform' => [
|
|
|
|
|
'php' => $constraint,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
] ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function providePhpValidCheck() {
|
|
|
|
|
return [
|
|
|
|
|
// [ phpVersion, constraint, expected ]
|
|
|
|
|
[ '7.0.23', '>= 7.0.0', true ],
|
|
|
|
|
[ '7.0.23', '^7.1.0', false ],
|
|
|
|
|
[ '7.0.23', '7.0.23', true ],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @expectedException UnexpectedValueException
|
|
|
|
|
*/
|
|
|
|
|
public function testPhpInvalidConstraint() {
|
|
|
|
|
$checker = new VersionChecker( '1.0.0', '7.0.0' );
|
|
|
|
|
$checker->checkArray( [
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'platform' => [
|
|
|
|
|
'php' => 'totallyinvalid',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providePhpInvalidVersion
|
|
|
|
|
* @expectedException UnexpectedValueException
|
|
|
|
|
*/
|
|
|
|
|
public function testPhpInvalidVersion( $phpVersion ) {
|
|
|
|
|
$checker = new VersionChecker( '1.0.0', $phpVersion );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function providePhpInvalidVersion() {
|
|
|
|
|
return [
|
|
|
|
|
// [ phpVersion ]
|
|
|
|
|
[ '7.abc' ],
|
|
|
|
|
[ '5.a.x' ],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
/**
|
|
|
|
|
* @dataProvider provideType
|
|
|
|
|
*/
|
|
|
|
|
public function testType( $given, $expected ) {
|
2018-09-08 00:02:53 +00:00
|
|
|
$checker = new VersionChecker( '1.0.0', '7.0.0' );
|
2018-06-15 15:51:22 +00:00
|
|
|
$checker->setLoadedExtensionsAndSkins( [
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
'FakeDependency' => [
|
|
|
|
|
'version' => '1.0.0',
|
|
|
|
|
],
|
2018-02-10 07:14:07 +00:00
|
|
|
'NoVersionGiven' => [],
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
] );
|
|
|
|
|
$this->assertEquals( $expected, $checker->checkArray( [
|
|
|
|
|
'FakeExtension' => $given,
|
2018-06-15 15:51:22 +00:00
|
|
|
] ) );
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function provideType() {
|
|
|
|
|
return [
|
|
|
|
|
// valid type
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'extensions' => [
|
2018-06-15 15:51:22 +00:00
|
|
|
'FakeDependency' => '1.0.0',
|
|
|
|
|
],
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
],
|
2018-06-15 15:51:22 +00:00
|
|
|
[],
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
2018-06-15 15:51:22 +00:00
|
|
|
'MediaWiki' => '1.0.0',
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
],
|
2018-06-15 15:51:22 +00:00
|
|
|
[],
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
],
|
2018-02-10 07:14:07 +00:00
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'extensions' => [
|
2018-06-15 15:51:22 +00:00
|
|
|
'NoVersionGiven' => '*',
|
|
|
|
|
],
|
2018-02-10 07:14:07 +00:00
|
|
|
],
|
|
|
|
|
[],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'extensions' => [
|
|
|
|
|
'NoVersionGiven' => '1.0',
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'incompatible' => 'FakeExtension',
|
|
|
|
|
'type' => 'incompatible-extensions',
|
|
|
|
|
'msg' => 'NoVersionGiven does not expose its version, but FakeExtension requires: 1.0.',
|
|
|
|
|
],
|
2018-02-10 07:14:07 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'extensions' => [
|
|
|
|
|
'Missing' => '*',
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'missing' => 'Missing',
|
|
|
|
|
'type' => 'missing-extensions',
|
|
|
|
|
'msg' => 'FakeExtension requires Missing to be installed.',
|
|
|
|
|
],
|
2018-02-10 07:14:07 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'extensions' => [
|
|
|
|
|
'FakeDependency' => '2.0.0',
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'incompatible' => 'FakeExtension',
|
|
|
|
|
'type' => 'incompatible-extensions',
|
|
|
|
|
// phpcs:ignore Generic.Files.LineLength.TooLong
|
|
|
|
|
'msg' => 'FakeExtension is not compatible with the current installed version of FakeDependency (1.0.0), it requires: 2.0.0.',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'skins' => [
|
|
|
|
|
'FakeSkin' => '*',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'missing' => 'FakeSkin',
|
|
|
|
|
'type' => 'missing-skins',
|
|
|
|
|
'msg' => 'FakeExtension requires FakeSkin to be installed.',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check, if a non-parsable version constraint does not throw an exception or
|
|
|
|
|
* returns any error message.
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidConstraint() {
|
2018-09-08 00:02:53 +00:00
|
|
|
$checker = new VersionChecker( '1.0.0', '7.0.0' );
|
2018-06-15 15:51:22 +00:00
|
|
|
$checker->setLoadedExtensionsAndSkins( [
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
'FakeDependency' => [
|
|
|
|
|
'version' => 'not really valid',
|
|
|
|
|
],
|
|
|
|
|
] );
|
2018-06-15 15:51:22 +00:00
|
|
|
$this->assertEquals( [
|
|
|
|
|
[
|
2018-04-08 23:26:01 +00:00
|
|
|
'type' => 'invalid-version',
|
2018-06-15 15:51:22 +00:00
|
|
|
'msg' => "FakeDependency does not have a valid version string.",
|
|
|
|
|
],
|
|
|
|
|
], $checker->checkArray( [
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'extensions' => [
|
|
|
|
|
'FakeDependency' => '1.24.3',
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
],
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
|
|
|
|
] ) );
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
|
2018-09-08 00:02:53 +00:00
|
|
|
$checker = new VersionChecker( '1.0.0', '7.0.0' );
|
2018-06-15 15:51:22 +00:00
|
|
|
$checker->setLoadedExtensionsAndSkins( [
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
'FakeDependency' => [
|
|
|
|
|
'version' => '1.24.3',
|
|
|
|
|
],
|
|
|
|
|
] );
|
|
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$this->setExpectedException( UnexpectedValueException::class );
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
$checker->checkArray( [
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'FakeDependency' => 'not really valid',
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
registration: Allow specifying extension dependencies
There are some extensoins that depend upon another extension or skin,
usually in different ways:
* A constant that is added in the dependency extension, and the
existence of is checked for. This is problematic because it requires a
specific load order.
* Checking whether a specific class exists. This is problematic because
it is extremely fragile, and breaks whenever the class is renamed.
* Checking ExtensionRegistry::isLoaded(). This is mostly there, but it
only checks at runtime, and doesn't provide any machine readable data.
Furthermore, developers implement each one differently, with very little
standardization.
With this, extensions may now specify what other extensions they depend
on. This is for explicit *hard* dependencies that must be installed.
For example:
"requires": {
"MediaWiki": ">= 1.25.0",
"extensions": {
"FakeExtension": "*"
},
"skins": {
"FakeSkin": "*"
}
}
This would add a minimum requirement on MediaWiki 1.25.0+ (already
implemented), as well as the requirement that the FakeExtension extension
needs to be installed, as well as the FakeSkin skin. A wildcard (*) is
used instead of an explicit version requirement as many extensions do
not actually version themselves, and there is no consistent versioning
scheme yet.
Bug: T117277
Change-Id: If1cccee1a16a867a71bb0285691c400443d8a30a
2016-12-03 18:19:25 +00:00
|
|
|
] );
|
|
|
|
|
}
|
2018-06-15 15:51:22 +00:00
|
|
|
|
2018-09-08 00:02:53 +00:00
|
|
|
public function provideInvalidDependency() {
|
|
|
|
|
return [
|
2018-06-15 15:51:22 +00:00
|
|
|
[
|
2018-09-08 00:02:53 +00:00
|
|
|
[
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'platform' => [
|
|
|
|
|
'undefinedPlatformDependency' => '*',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'undefinedPlatformDependency',
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
2018-09-08 00:02:53 +00:00
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'undefinedDependencyType' => '*',
|
|
|
|
|
],
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
2018-09-08 00:02:53 +00:00
|
|
|
'undefinedDependencyType',
|
2018-06-15 15:51:22 +00:00
|
|
|
],
|
2018-09-08 00:02:53 +00:00
|
|
|
// T197478
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'FakeExtension' => [
|
|
|
|
|
'skin' => [
|
|
|
|
|
'FakeSkin' => '*',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'skin',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideInvalidDependency
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidDependency( $depencency, $type ) {
|
|
|
|
|
$checker = new VersionChecker( '1.0.0', '7.0.0' );
|
|
|
|
|
$this->setExpectedException(
|
|
|
|
|
UnexpectedValueException::class,
|
|
|
|
|
"Dependency type $type unknown in FakeExtension"
|
|
|
|
|
);
|
|
|
|
|
$checker->checkArray( $depencency );
|
2018-06-15 15:51:22 +00:00
|
|
|
}
|
2015-05-14 05:51:55 +00:00
|
|
|
}
|