From: Antoine Musso Date: Thu, 21 Aug 2014 19:54:51 +0000 (+0200) Subject: tests: avoid sql queries in TitleTest X-Git-Tag: 1.31.0-rc.0~14314^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=e5eb717d251a007882a1e2703f9354c90d1e70e5;p=lhc%2Fweb%2Fwiklou.git tests: avoid sql queries in TitleTest testIsAlwaysKnown was invoked on an interwiki link. To have the test pass, we used addDBData() to inject the interwiki in the database. This end up being execute on each test when it is only needed for a single assertion. Instead of creating a Title, use Title::makeTitle() to populate the interwiki, thus letting us avoid the database hits. Random timing: 1.20s -> 150ms. Change-Id: I63a4e7b9af5eacb7dc1de4b33b8e631e6c3f1fa6 --- diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index 53e8dc230b..d0f418b292 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -1,9 +1,6 @@ db->replace( 'interwiki', 'iw_prefix', - array( - 'iw_prefix' => 'externalwiki', - 'iw_url' => '//example.com/$1', - 'iw_api' => '//example.com/api.php', - 'iw_wikiid' => '', - 'iw_local' => 0, - 'iw_trans' => 0, - ) - ); - } - /** * @covers Title::legalChars */ @@ -640,7 +624,14 @@ class TitleTest extends MediaWikiTestCase { array( 'Special:SomeNonexistentSpecialPage', false ), array( 'MediaWiki:Parentheses', true ), array( 'MediaWiki:Some nonexistent message', false ), - array( 'externalwiki:Interwiki link', true ), ); } + + /** + * @covers Title::isAlwaysKnown + */ + public function testIsAlwaysKnownOnInterwiki() { + $title = Title::makeTitle( NS_MAIN, 'Interwiki link', '', 'externalwiki' ); + $this->assertTrue( $title->isAlwaysKnown() ); + } }