summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/registration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/registration')
-rw-r--r--tests/phpunit/includes/registration/CoreVersionCheckerTest.php38
-rw-r--r--tests/phpunit/includes/registration/ExtensionProcessorTest.php16
-rw-r--r--tests/phpunit/includes/registration/ExtensionRegistryTest.php2
3 files changed, 48 insertions, 8 deletions
diff --git a/tests/phpunit/includes/registration/CoreVersionCheckerTest.php b/tests/phpunit/includes/registration/CoreVersionCheckerTest.php
new file mode 100644
index 00000000..bc154b37
--- /dev/null
+++ b/tests/phpunit/includes/registration/CoreVersionCheckerTest.php
@@ -0,0 +1,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 ),
+ );
+ }
+}
diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
index ff6be6c2..1cb8a5d9 100644
--- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php
+++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
@@ -14,7 +14,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
*
* @var array
*/
- static $default = array(
+ public static $default = array(
'name' => 'FooBar',
);
@@ -28,7 +28,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
'@metadata' => array( 'foobarbaz' ),
'AnAttribute' => array( 'omg' ),
'AutoloadClasses' => array( 'FooBar' => 'includes/FooBar.php' ),
- ) );
+ ), 1 );
$extracted = $processor->getExtractedInfo();
$attributes = $extracted['attributes'];
@@ -96,7 +96,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
*/
public function testRegisterHooks( $pre, $info, $expected ) {
$processor = new MockExtensionProcessor( array( 'wgHooks' => $pre ) );
- $processor->extractInfo( $this->dir, $info );
+ $processor->extractInfo( $this->dir, $info, 1 );
$extracted = $processor->getExtractedInfo();
$this->assertEquals( $expected, $extracted['globals']['wgHooks'] );
}
@@ -119,8 +119,8 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
'Bar' => 'somevalue'
),
) + self::$default;
- $processor->extractInfo( $this->dir, $info );
- $processor->extractInfo( $this->dir, $info2 );
+ $processor->extractInfo( $this->dir, $info, 1 );
+ $processor->extractInfo( $this->dir, $info2, 1 );
$extracted = $processor->getExtractedInfo();
$this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
$this->assertEquals( 10, $extracted['globals']['wgFoo'] );
@@ -159,7 +159,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
*/
public function testExtracttExtensionMessagesFiles( $input, $expected ) {
$processor = new ExtensionProcessor();
- $processor->extractInfo( $this->dir, $input + self::$default );
+ $processor->extractInfo( $this->dir, $input + self::$default, 1 );
$out = $processor->getExtractedInfo();
foreach ( $expected as $key => $value ) {
$this->assertEquals( $value, $out['globals'][$key] );
@@ -187,7 +187,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
*/
public function testExtractMessagesDirs( $input, $expected ) {
$processor = new ExtensionProcessor();
- $processor->extractInfo( $this->dir, $input + self::$default );
+ $processor->extractInfo( $this->dir, $input + self::$default, 1 );
$out = $processor->getExtractedInfo();
foreach ( $expected as $key => $value ) {
$this->assertEquals( $value, $out['globals'][$key] );
@@ -200,7 +200,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
*/
public function testExtractResourceLoaderModules( $input, $expected ) {
$processor = new ExtensionProcessor();
- $processor->extractInfo( $this->dir, $input + self::$default );
+ $processor->extractInfo( $this->dir, $input + self::$default, 1 );
$out = $processor->getExtractedInfo();
foreach ( $expected as $key => $value ) {
$this->assertEquals( $value, $out['globals'][$key] );
diff --git a/tests/phpunit/includes/registration/ExtensionRegistryTest.php b/tests/phpunit/includes/registration/ExtensionRegistryTest.php
index c3a0c8d4..201cbfcd 100644
--- a/tests/phpunit/includes/registration/ExtensionRegistryTest.php
+++ b/tests/phpunit/includes/registration/ExtensionRegistryTest.php
@@ -218,6 +218,7 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
'user' => array(
'right' => true,
'somethingtwo' => false,
+ 'nonduplicated' => true,
),
ExtensionRegistry::MERGE_STRATEGY => 'array_plus_2d',
),
@@ -233,6 +234,7 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
'user' => array(
'somethingtwo' => true,
'right' => true,
+ 'nonduplicated' => true,
)
),
),