registration: Generalize CoreVersionChecker to VersionChecker
[lhc/web/wiklou.git] / tests / phpunit / includes / registration / VersionCheckerTest.php
1 <?php
2
3 /**
4 * @covers CoreVersionChecker
5 */
6 class CoreVersionCheckerTest extends PHPUnit_Framework_TestCase {
7 /**
8 * @dataProvider provideCheck
9 */
10 public function testCheck( $coreVersion, $constraint, $expected ) {
11 $checker = new VersionChecker();
12 $checker->setCoreVersion( $coreVersion );
13 $this->assertEquals( $expected, !(bool)$checker->checkArray( [
14 'FakeExtension' => [
15 'MediaWiki' => $constraint,
16 ],
17 ] )
18 );
19 }
20
21 public static function provideCheck() {
22 return [
23 // [ $wgVersion, constraint, expected ]
24 [ '1.25alpha', '>= 1.26', false ],
25 [ '1.25.0', '>= 1.26', false ],
26 [ '1.26alpha', '>= 1.26', true ],
27 [ '1.26alpha', '>= 1.26.0', true ],
28 [ '1.26alpha', '>= 1.26.0-stable', false ],
29 [ '1.26.0', '>= 1.26.0-stable', true ],
30 [ '1.26.1', '>= 1.26.0-stable', true ],
31 [ '1.27.1', '>= 1.26.0-stable', true ],
32 [ '1.26alpha', '>= 1.26.1', false ],
33 [ '1.26alpha', '>= 1.26alpha', true ],
34 [ '1.26alpha', '>= 1.25', true ],
35 [ '1.26.0-alpha.14', '>= 1.26.0-alpha.15', false ],
36 [ '1.26.0-alpha.14', '>= 1.26.0-alpha.10', true ],
37 [ '1.26.1', '>= 1.26.2, <=1.26.0', false ],
38 [ '1.26.1', '^1.26.2', false ],
39 // Accept anything for un-parsable version strings
40 [ '1.26mwf14', '== 1.25alpha', true ],
41 [ 'totallyinvalid', '== 1.0', true ],
42 ];
43 }
44 }