aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser
diff options
context:
space:
mode:
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>2012-01-07 12:19:10 +0000
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>2012-01-07 12:19:10 +0000
commit40c98e0ad1035d7006c5740e13ced123f0fa4c7c (patch)
treeff40b7b9403a516252326f654c9c17c4896cee34 /tests/parser
parent412d71adf520925a23b6d81ce4922167b09fcc6c (diff)
downloadmediawikicore-40c98e0ad1035d7006c5740e13ced123f0fa4c7c.tar.gz
mediawikicore-40c98e0ad1035d7006c5740e13ced123f0fa4c7c.zip
* Don't select (even twice for PHPUnit tests) "FOR UPDATE", but use the master database directly instead
* Also pass the line number * Removed useless usage of $title when throwing the exception about invalid since that variable is always null * Added $ignoreDuplicate parameter to ParserTest::addArticle()
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/108316
Diffstat (limited to 'tests/parser')
-rw-r--r--tests/parser/parserTest.inc21
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc
index 5584596648b5..ac557a35fd1a 100644
--- a/tests/parser/parserTest.inc
+++ b/tests/parser/parserTest.inc
@@ -1162,29 +1162,34 @@ class ParserTest {
* @param $name String: the title, including any prefix
* @param $text String: the article text
* @param $line Integer: the input line number, for reporting errors
+ * @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages
*/
- static public function addArticle( $name, $text, $line = 'unknown' ) {
+ static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
global $wgCapitalLinks;
- $text = self::chomp($text);
-
$oldCapitalLinks = $wgCapitalLinks;
$wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
+ $text = self::chomp( $text );
$name = self::chomp( $name );
+
$title = Title::newFromText( $name );
if ( is_null( $title ) ) {
- throw new MWException( "invalid title ('$name' => '$title') at line $line\n" );
+ throw new MWException( "invalid title '$name' at line $line\n" );
}
- $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
+ $page = WikiPage::factory( $title );
+ $page->loadPageData( 'fromdbmaster' );
- if ( $aid != 0 ) {
- throw new MWException( "duplicate article '$name' at line $line\n" );
+ if ( $page->exists() ) {
+ if ( $ignoreDuplicate == 'ignoreduplicate' ) {
+ return;
+ } else {
+ throw new MWException( "duplicate article '$name' at line $line\n" );
+ }
}
- $page = WikiPage::factory( $title );
$page->doEdit( $text, '', EDIT_NEW );
$wgCapitalLinks = $oldCapitalLinks;