4 * @covers VersionChecker
6 class VersionCheckerTest
extends PHPUnit_Framework_TestCase
{
8 * @dataProvider provideCheck
10 public function testCheck( $coreVersion, $constraint, $expected ) {
11 $checker = new VersionChecker( $coreVersion );
12 $this->assertEquals( $expected, !(bool)$checker->checkArray( [
14 'MediaWiki' => $constraint,
20 public static function provideCheck() {
22 // [ $wgVersion, constraint, expected ]
23 [ '1.25alpha', '>= 1.26', false ],
24 [ '1.25.0', '>= 1.26', false ],
25 [ '1.26alpha', '>= 1.26', true ],
26 [ '1.26alpha', '>= 1.26.0', true ],
27 [ '1.26alpha', '>= 1.26.0-stable', false ],
28 [ '1.26.0', '>= 1.26.0-stable', true ],
29 [ '1.26.1', '>= 1.26.0-stable', true ],
30 [ '1.27.1', '>= 1.26.0-stable', true ],
31 [ '1.26alpha', '>= 1.26.1', false ],
32 [ '1.26alpha', '>= 1.26alpha', true ],
33 [ '1.26alpha', '>= 1.25', true ],
34 [ '1.26.0-alpha.14', '>= 1.26.0-alpha.15', false ],
35 [ '1.26.0-alpha.14', '>= 1.26.0-alpha.10', true ],
36 [ '1.26.1', '>= 1.26.2, <=1.26.0', false ],
37 [ '1.26.1', '^1.26.2', false ],
38 // Accept anything for un-parsable version strings
39 [ '1.26mwf14', '== 1.25alpha', true ],
40 [ 'totallyinvalid', '== 1.0', true ],
45 * @dataProvider provideType
47 public function testType( $given, $expected ) {
48 $checker = new VersionChecker( '1.0.0' );
50 ->setLoadedExtensionsAndSkins( [
55 $this->assertEquals( $expected, $checker->checkArray( [
56 'FakeExtension' => $given,
61 public static function provideType() {
67 'FakeDependency' => '1.0.0'
74 'MediaWiki' => '1.0.0'
82 * Check, if a non-parsable version constraint does not throw an exception or
83 * returns any error message.
85 public function testInvalidConstraint() {
86 $checker = new VersionChecker( '1.0.0' );
88 ->setLoadedExtensionsAndSkins( [
90 'version' => 'not really valid',
93 $this->assertEquals( [ "FakeDependency does not have a valid version string." ],
94 $checker->checkArray( [
97 'FakeDependency' => '1.24.3',
103 $checker = new VersionChecker( '1.0.0' );
105 ->setLoadedExtensionsAndSkins( [
106 'FakeDependency' => [
107 'version' => '1.24.3',
111 $this->setExpectedException( 'UnexpectedValueException' );
112 $checker->checkArray( [
114 'FakeDependency' => 'not really valid',