From ce4a6e26ea5388f0694e34955959e921290a62d9 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 26 Apr 2012 12:11:01 +0200 Subject: [PATCH] reset namespace caches when testing extra namespace handling --- tests/phpunit/includes/ContentHandlerTest.php | 46 +++++++++++-------- tests/phpunit/includes/RevisionTest.php | 10 +++- tests/phpunit/includes/TitleMethodsTest.php | 10 +++- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/includes/ContentHandlerTest.php b/tests/phpunit/includes/ContentHandlerTest.php index f63d5def07..2a1c49c505 100644 --- a/tests/phpunit/includes/ContentHandlerTest.php +++ b/tests/phpunit/includes/ContentHandlerTest.php @@ -2,6 +2,32 @@ class ContentHandlerTest extends MediaWikiTestCase { + public function setup() { + global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang; + + $wgExtraNamespaces[ 12312 ] = 'Dummy'; + $wgExtraNamespaces[ 12313 ] = 'Dummy_talk'; + + $wgNamespaceContentModels[ 12312 ] = 'DUMMY'; + $wgContentHandlers[ 'DUMMY' ] = 'DummyContentHandlerForTesting'; + + MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache + $wgContLang->resetNamespaces(); # reset namespace cache + } + + public function teardown() { + global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang; + + unset( $wgExtraNamespaces[ 12312 ] ); + unset( $wgExtraNamespaces[ 12313 ] ); + + unset( $wgNamespaceContentModels[ 12312 ] ); + unset( $wgContentHandlers[ 'DUMMY' ] ); + + MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache + $wgContLang->resetNamespaces(); # reset namespace cache + } + public function dataGetDefaultModelFor() { return array( array( 'Foo', CONTENT_MODEL_WIKITEXT ), @@ -143,26 +169,6 @@ class ContentHandlerTest extends MediaWikiTestCase { } - public function setup() { - global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers; - - $wgExtraNamespaces[ 12312 ] = 'Dummy'; - $wgExtraNamespaces[ 12313 ] = 'Dummy_talk'; - - $wgNamespaceContentModels[ 12312 ] = 'DUMMY'; - $wgContentHandlers[ 'DUMMY' ] = 'DummyContentHandlerForTesting'; - } - - public function teardown() { - global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers; - - unset( $wgExtraNamespaces[ 12312 ] ); - unset( $wgExtraNamespaces[ 12313 ] ); - - unset( $wgNamespaceContentModels[ 12312 ] ); - unset( $wgContentHandlers[ 'DUMMY' ] ); - } - } class DummyContentHandlerForTesting extends ContentHandler { diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 14e2504ab6..a529e97624 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -22,21 +22,29 @@ class RevisionTest extends MediaWikiTestCase { $GLOBALS[$var] = $data; } - global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers; + global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang; $wgExtraNamespaces[ 12312 ] = 'Dummy'; $wgExtraNamespaces[ 12313 ] = 'Dummy_talk'; $wgNamespaceContentModels[ 12312 ] = 'DUMMY'; $wgContentHandlers[ 'DUMMY' ] = 'DummyContentHandlerForTesting'; + MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache + $wgContLang->resetNamespaces(); # reset namespace cache + global $wgContentHandlerTextFallback; $wgContentHandlerTextFallback = 'ignore'; } function tearDown() { + global $wgContLang; + foreach ( $this->saveGlobals as $var => $data ) { $GLOBALS[$var] = $data; } + + MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache + $wgContLang->resetNamespaces(); # reset namespace cache } function testGetRevisionText() { diff --git a/tests/phpunit/includes/TitleMethodsTest.php b/tests/phpunit/includes/TitleMethodsTest.php index 8d3b76c5da..a6fce7e774 100644 --- a/tests/phpunit/includes/TitleMethodsTest.php +++ b/tests/phpunit/includes/TitleMethodsTest.php @@ -3,21 +3,27 @@ class TitleMethodsTest extends MediaWikiTestCase { public function setup() { - global $wgExtraNamespaces, $wgNamespaceContentModels; + global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContLang; $wgExtraNamespaces[ 12302 ] = 'TEST-JS'; $wgExtraNamespaces[ 12303 ] = 'TEST-JS_TALK'; $wgNamespaceContentModels[ 12302 ] = CONTENT_MODEL_JAVASCRIPT; + + MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache + $wgContLang->resetNamespaces(); # reset namespace cache } public function teardown() { - global $wgExtraNamespaces, $wgNamespaceContentModels; + global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContLang; unset( $wgExtraNamespaces[ 12302 ] ); unset( $wgExtraNamespaces[ 12303 ] ); unset( $wgNamespaceContentModels[ 12302 ] ); + + MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache + $wgContLang->resetNamespaces(); # reset namespace cache } public function dataEquals() { -- 2.20.1