X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FArticleTablesTest.php;h=9f2b7a053457e5decd1fee36b0765e8a090b8517;hb=9badb24d1a0d5cec6620c6385225df1a2302c946;hp=7f9a0237659b2d2c3a66f93bb48431a1369aa527;hpb=aa5e15357aab7365815c154fd86bdaa6f968b97a;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/ArticleTablesTest.php b/tests/phpunit/includes/ArticleTablesTest.php index 7f9a023765..9f2b7a0534 100644 --- a/tests/phpunit/includes/ArticleTablesTest.php +++ b/tests/phpunit/includes/ArticleTablesTest.php @@ -4,32 +4,49 @@ * @group Database */ class ArticleTablesTest extends MediaWikiLangTestCase { - /** + * Make sure that bug 14404 doesn't strike again. We don't want + * templatelinks based on the user language when {{int:}} is used, only the + * content language. + * * @covers Title::getTemplateLinksFrom * @covers Title::getLinksFrom */ - public function testbug14404() { - global $wgContLang, $wgLanguageCode, $wgLang; - + public function testTemplatelinksUsesContentLanguage() { $title = Title::newFromText( 'Bug 14404' ); $page = WikiPage::factory( $title ); $user = new User(); $user->mRights = array( 'createpage', 'edit', 'purge' ); - $wgLanguageCode = 'es'; - $wgContLang = Language::factory( 'es' ); + $this->setMwGlobals( 'wgLanguageCode', 'es' ); + $this->setMwGlobals( 'wgContLang', Language::factory( 'es' ) ); + $this->setMwGlobals( 'wgLang', Language::factory( 'fr' ) ); - $wgLang = Language::factory( 'fr' ); - $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', 0, false, $user ); + $page->doEditContent( + new WikitextContent( '{{:{{int:history}}}}' ), + 'Test code for bug 14404', + 0, + false, + $user + ); $templates1 = $title->getTemplateLinksFrom(); - $wgLang = Language::factory( 'de' ); - $page = WikiPage::factory( $title ); // In order to force the rerendering of the same wikitext + $this->setMwGlobals( 'wgLang', Language::factory( 'de' ) ); + $page = WikiPage::factory( $title ); // In order to force the re-rendering of the same wikitext // We need an edit, a purge is not enough to regenerate the tables - $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', EDIT_UPDATE, false, $user ); + $page->doEditContent( + new WikitextContent( '{{:{{int:history}}}}' ), + 'Test code for bug 14404', + EDIT_UPDATE, + false, + $user + ); $templates2 = $title->getTemplateLinksFrom(); + /** + * @var Title[] $templates1 + * @var Title[] $templates2 + */ $this->assertEquals( $templates1, $templates2 ); $this->assertEquals( $templates1[0]->getFullText(), 'Historial' ); }