From f129b1baf964b00ec375b20fd12ef5e4e2e79f79 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 7 Jul 2014 16:21:09 -0700 Subject: [PATCH] Limit test leakage, $wgCapitalLinks expected to be true Change-Id: I0f837d29595abefaebeb67d6cc62ea48838d626a --- tests/phpunit/includes/LinkerTest.php | 1 + tests/phpunit/includes/LinksUpdateTest.php | 4 ++++ tests/phpunit/includes/SampleTest.php | 1 + tests/phpunit/includes/WikiPageTest.php | 4 ++++ tests/phpunit/includes/api/query/ApiQueryTest.php | 9 ++++++++- tests/phpunit/includes/content/TextContentTest.php | 1 + tests/phpunit/includes/site/MediaWikiSiteTest.php | 4 ++++ tests/phpunit/includes/title/MediaWikiTitleCodecTest.php | 1 + 8 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 4d62cc7479..72114e963e 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -94,6 +94,7 @@ class LinkerTest extends MediaWikiLangTestCase { 'wgScript' => '/wiki/index.php', 'wgArticlePath' => '/wiki/$1', 'wgWellFormedXml' => true, + 'wgCapitalLinks' => true, ) ); if ( $title === false ) { diff --git a/tests/phpunit/includes/LinksUpdateTest.php b/tests/phpunit/includes/LinksUpdateTest.php index 9ff547c1d5..a5dac8d809 100644 --- a/tests/phpunit/includes/LinksUpdateTest.php +++ b/tests/phpunit/includes/LinksUpdateTest.php @@ -186,6 +186,10 @@ class LinksUpdateTest extends MediaWikiTestCase { * @covers ParserOutput::addLanguageLink */ public function testUpdate_langlinks() { + $this->setMwGlobals( array( + 'wgCapitalLinks' => true, + ) ); + /** @var ParserOutput $po */ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); diff --git a/tests/phpunit/includes/SampleTest.php b/tests/phpunit/includes/SampleTest.php index 758c2e277b..6fdc23911f 100644 --- a/tests/phpunit/includes/SampleTest.php +++ b/tests/phpunit/includes/SampleTest.php @@ -16,6 +16,7 @@ class TestSample extends MediaWikiLangTestCase { $this->setMwGlobals( array( 'wgContLang' => Language::factory( 'en' ), 'wgLanguageCode' => 'en', + 'wgCapitalLinks' => true, ) ); } diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php index 78457d2d1a..7f7945b8d8 100644 --- a/tests/phpunit/includes/WikiPageTest.php +++ b/tests/phpunit/includes/WikiPageTest.php @@ -499,6 +499,10 @@ class WikiPageTest extends MediaWikiLangTestCase { * @covers WikiPage::getRedirectTarget */ public function testGetRedirectTarget( $title, $model, $text, $target ) { + $this->setMwGlobals( array( + 'wgCapitalLinks' => true, + ) ); + $page = $this->createPage( $title, $text, $model ); # sanity check, because this test seems to fail for no reason for some people. diff --git a/tests/phpunit/includes/api/query/ApiQueryTest.php b/tests/phpunit/includes/api/query/ApiQueryTest.php index ea0b3235ab..7b686a3154 100644 --- a/tests/phpunit/includes/api/query/ApiQueryTest.php +++ b/tests/phpunit/includes/api/query/ApiQueryTest.php @@ -36,9 +36,12 @@ class ApiQueryTest extends ApiTestCase { } public function testTitlesGetNormalized() { - global $wgMetaNamespace; + $this->setMwGlobals( array( + 'wgCapitalLinks' => true, + ) ); + $data = $this->doApiRequest( array( 'action' => 'query', 'titles' => 'Project:articleA|article_B' ) ); @@ -97,6 +100,10 @@ class ApiQueryTest extends ApiTestCase { * @dataProvider provideTestTitlePartToKey */ function testTitlePartToKey( $titlePart, $namespace, $expected, $expectException ) { + $this->setMwGlobals( array( + 'wgCapitalLinks' => true, + ) ); + $api = new MockApiQueryBase(); $exceptionCaught = false; try { diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index 03cbbc0153..2f8110945e 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -31,6 +31,7 @@ class TextContentTest extends MediaWikiLangTestCase { ), 'wgUseTidy' => false, 'wgAlwaysUseTidy' => false, + 'wgCapitalLinks' => true, ) ); // bypass hooks that force custom rendering diff --git a/tests/phpunit/includes/site/MediaWikiSiteTest.php b/tests/phpunit/includes/site/MediaWikiSiteTest.php index 15b88658d7..c3fd155743 100644 --- a/tests/phpunit/includes/site/MediaWikiSiteTest.php +++ b/tests/phpunit/includes/site/MediaWikiSiteTest.php @@ -32,6 +32,10 @@ class MediaWikiSiteTest extends SiteTest { public function testNormalizePageTitle() { + $this->setMwGlobals( array( + 'wgCapitalLinks' => true, + ) ); + $site = new MediaWikiSite(); $site->setGlobalId( 'enwiki' ); diff --git a/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php b/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php index 1e5aca9129..2cf86636c4 100644 --- a/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php +++ b/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php @@ -40,6 +40,7 @@ class MediaWikiTitleCodecTest extends MediaWikiTestCase { 'wgAllowUserJs' => false, 'wgDefaultLanguageVariant' => false, 'wgLocalInterwikis' => array( 'localtestiw' ), + 'wgCapitalLinks' => true, // NOTE: this is why global state is evil. // TODO: refactor access to the interwiki codes so it can be injected. -- 2.20.1