Hashar has uploaded a new change for review.
https://gerrit.wikimedia.org/r/155615
Change subject: tests: avoid sql queries in TitleTest
......................................................................
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
---
M tests/phpunit/includes/TitleTest.php
1 file changed, 8 insertions(+), 17 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/15/155615/1
diff --git a/tests/phpunit/includes/TitleTest.php
b/tests/phpunit/includes/TitleTest.php
index 53e8dc2..d0f418b 100644
--- a/tests/phpunit/includes/TitleTest.php
+++ b/tests/phpunit/includes/TitleTest.php
@@ -1,9 +1,6 @@
<?php
/**
- * @group Database
- * ^--- needed for language cache stuff
- *
* @group Title
*/
class TitleTest extends MediaWikiTestCase {
@@ -18,19 +15,6 @@
'wgAllowUserJs' => false,
'wgDefaultLanguageVariant' => false,
) );
- }
-
- public function addDBData() {
- $this->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,
- )
- );
}
/**
@@ -640,7 +624,14 @@
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() );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/155615
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63a4e7b9af5eacb7dc1de4b33b8e631e6c3f1fa6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits