summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/registration/CoreVersionCheckerTest.php
blob: bc154b3713d99549261708ee34e5e960e63efd76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 * @covers CoreVersionChecker
 */
class CoreVersionCheckerTest extends PHPUnit_Framework_TestCase {
	/**
	 * @dataProvider provideCheck
	 */
	public function testCheck( $coreVersion, $constraint, $expected ) {
		$checker = new CoreVersionChecker( $coreVersion );
		$this->assertEquals( $expected, $checker->check( $constraint ) );
	}

	public static function provideCheck() {
		return array(
			// array( $wgVersion, constraint, expected )
			array( '1.25alpha', '>= 1.26', false ),
			array( '1.25.0', '>= 1.26', false ),
			array( '1.26alpha', '>= 1.26', true ),
			array( '1.26alpha', '>= 1.26.0', true ),
			array( '1.26alpha', '>= 1.26.0-stable', false ),
			array( '1.26.0', '>= 1.26.0-stable', true ),
			array( '1.26.1', '>= 1.26.0-stable', true ),
			array( '1.27.1', '>= 1.26.0-stable', true ),
			array( '1.26alpha', '>= 1.26.1', false ),
			array( '1.26alpha', '>= 1.26alpha', true ),
			array( '1.26alpha', '>= 1.25', true ),
			array( '1.26.0-alpha.14', '>= 1.26.0-alpha.15', false ),
			array( '1.26.0-alpha.14', '>= 1.26.0-alpha.10', true ),
			array( '1.26.1', '>= 1.26.2, <=1.26.0', false ),
			array( '1.26.1', '^1.26.2', false ),
			// Accept anything for un-parsable version strings
			array( '1.26mwf14', '== 1.25alpha', true ),
			array( 'totallyinvalid', '== 1.0', true ),
		);
	}
}