summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/phpunit/includes/registration/ExtensionProcessorTest.php38
-rw-r--r--tests/phpunit/includes/registration/ExtensionRegistryTest.php49
2 files changed, 82 insertions, 5 deletions
diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
index 8715711f..ff6be6c2 100644
--- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php
+++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
@@ -38,24 +38,29 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
}
public static function provideRegisterHooks() {
+ $merge = array( ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive' );
+ // Format:
+ // Current $wgHooks
+ // Content in extension.json
+ // Expected value of $wgHooks
return array(
// No hooks
array(
array(),
self::$default,
- array(),
+ $merge,
),
// No current hooks, adding one for "FooBaz"
array(
array(),
array( 'Hooks' => array( 'FooBaz' => 'FooBazCallback' ) ) + self::$default,
- array( 'FooBaz' => array( 'FooBazCallback' ) ),
+ array( 'FooBaz' => array( 'FooBazCallback' ) ) + $merge,
),
// Hook for "FooBaz", adding another one
array(
array( 'FooBaz' => array( 'PriorCallback' ) ),
array( 'Hooks' => array( 'FooBaz' => 'FooBazCallback' ) ) + self::$default,
- array( 'FooBaz' => array( 'PriorCallback', 'FooBazCallback' ) ),
+ array( 'FooBaz' => array( 'PriorCallback', 'FooBazCallback' ) ) + $merge,
),
// Hook for "BarBaz", adding one for "FooBaz"
array(
@@ -64,7 +69,23 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
array(
'BarBaz' => array( 'BarBazCallback' ),
'FooBaz' => array( 'FooBazCallback' ),
- ),
+ ) + $merge,
+ ),
+ // Callbacks for FooBaz wrapped in an array
+ array(
+ array(),
+ array( 'Hooks' => array( 'FooBaz' => array( 'Callback1' ) ) ) + self::$default,
+ array(
+ 'FooBaz' => array( 'Callback1' ),
+ ) + $merge,
+ ),
+ // Multiple callbacks for FooBaz hook
+ array(
+ array(),
+ array( 'Hooks' => array( 'FooBaz' => array( 'Callback1', 'Callback2' ) ) ) + self::$default,
+ array(
+ 'FooBaz' => array( 'Callback1', 'Callback2' ),
+ ) + $merge,
),
);
}
@@ -92,11 +113,20 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
'@IGNORED' => 'yes',
),
) + self::$default;
+ $info2 = array(
+ 'config' => array(
+ '_prefix' => 'eg',
+ 'Bar' => 'somevalue'
+ ),
+ ) + self::$default;
$processor->extractInfo( $this->dir, $info );
+ $processor->extractInfo( $this->dir, $info2 );
$extracted = $processor->getExtractedInfo();
$this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
$this->assertEquals( 10, $extracted['globals']['wgFoo'] );
$this->assertArrayNotHasKey( 'wg@IGNORED', $extracted['globals'] );
+ // Custom prefix:
+ $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
}
public static function provideExtracttExtensionMessagesFiles() {
diff --git a/tests/phpunit/includes/registration/ExtensionRegistryTest.php b/tests/phpunit/includes/registration/ExtensionRegistryTest.php
index d7d4f198..c3a0c8d4 100644
--- a/tests/phpunit/includes/registration/ExtensionRegistryTest.php
+++ b/tests/phpunit/includes/registration/ExtensionRegistryTest.php
@@ -102,6 +102,50 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
)
),
array(
+ 'Global already set, 1d array that appends',
+ array(
+ 'mwAvailableRights' => array(
+ 'foobar',
+ 'foo'
+ ),
+ ),
+ array(
+ 'mwAvailableRights' => array(
+ 'barbaz',
+ ),
+ ),
+ array(
+ 'mwAvailableRights' => array(
+ 'barbaz',
+ 'foobar',
+ 'foo',
+ ),
+ )
+ ),
+ array(
+ 'Global already set, array with integer keys',
+ array(
+ 'mwNamespacesFoo' => array(
+ 100 => true,
+ 102 => false
+ ),
+ ),
+ array(
+ 'mwNamespacesFoo' => array(
+ 100 => false,
+ 500 => true,
+ ExtensionRegistry::MERGE_STRATEGY => 'array_plus',
+ ),
+ ),
+ array(
+ 'mwNamespacesFoo' => array(
+ 100 => true,
+ 102 => false,
+ 500 => true,
+ ),
+ )
+ ),
+ array(
'No global already set, $wgHooks',
array(
'wgHooks' => array(),
@@ -111,6 +155,7 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
'FooBarEvent' => array(
'FooBarClass::onFooBarEvent'
),
+ ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive'
),
),
array(
@@ -138,6 +183,7 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
'FooBarEvent' => array(
'BazBarClass::onFooBarEvent',
),
+ ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive',
),
),
array(
@@ -172,7 +218,8 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
'user' => array(
'right' => true,
'somethingtwo' => false,
- )
+ ),
+ ExtensionRegistry::MERGE_STRATEGY => 'array_plus_2d',
),
),
array(