Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php |
— | — | @@ -698,7 +698,7 @@ |
699 | 699 | //Various action functions |
700 | 700 | |
701 | 701 | public function addArticle( $name, $text, $line ) { |
702 | | - self::$articles[$name] = $text; |
| 702 | + self::$articles[$name] = array( $text, $line ); |
703 | 703 | } |
704 | 704 | |
705 | 705 | public function publishTestArticles() { |
— | — | @@ -706,12 +706,9 @@ |
707 | 707 | return; |
708 | 708 | } |
709 | 709 | |
710 | | - foreach ( self::$articles as $name => $text ) { |
711 | | - $title = Title::newFromText( $name ); |
712 | | - |
713 | | - if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) { |
714 | | - ParserTest::addArticle( $name, $text ); |
715 | | - } |
| 710 | + foreach ( self::$articles as $name => $info ) { |
| 711 | + list( $text, $line ) = $info; |
| 712 | + ParserTest::addArticle( $name, $text, $line, 'ignoreduplicate' ); |
716 | 713 | } |
717 | 714 | } |
718 | 715 | |
Index: trunk/phase3/tests/parser/parserTest.inc |
— | — | @@ -1162,29 +1162,34 @@ |
1163 | 1163 | * @param $name String: the title, including any prefix |
1164 | 1164 | * @param $text String: the article text |
1165 | 1165 | * @param $line Integer: the input line number, for reporting errors |
| 1166 | + * @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages |
1166 | 1167 | */ |
1167 | | - static public function addArticle( $name, $text, $line = 'unknown' ) { |
| 1168 | + static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) { |
1168 | 1169 | global $wgCapitalLinks; |
1169 | 1170 | |
1170 | | - $text = self::chomp($text); |
1171 | | - |
1172 | 1171 | $oldCapitalLinks = $wgCapitalLinks; |
1173 | 1172 | $wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637 |
1174 | 1173 | |
| 1174 | + $text = self::chomp( $text ); |
1175 | 1175 | $name = self::chomp( $name ); |
| 1176 | + |
1176 | 1177 | $title = Title::newFromText( $name ); |
1177 | 1178 | |
1178 | 1179 | if ( is_null( $title ) ) { |
1179 | | - throw new MWException( "invalid title ('$name' => '$title') at line $line\n" ); |
| 1180 | + throw new MWException( "invalid title '$name' at line $line\n" ); |
1180 | 1181 | } |
1181 | 1182 | |
1182 | | - $aid = $title->getArticleID( Title::GAID_FOR_UPDATE ); |
| 1183 | + $page = WikiPage::factory( $title ); |
| 1184 | + $page->loadPageData( 'fromdbmaster' ); |
1183 | 1185 | |
1184 | | - if ( $aid != 0 ) { |
1185 | | - throw new MWException( "duplicate article '$name' at line $line\n" ); |
| 1186 | + if ( $page->exists() ) { |
| 1187 | + if ( $ignoreDuplicate == 'ignoreduplicate' ) { |
| 1188 | + return; |
| 1189 | + } else { |
| 1190 | + throw new MWException( "duplicate article '$name' at line $line\n" ); |
| 1191 | + } |
1186 | 1192 | } |
1187 | 1193 | |
1188 | | - $page = WikiPage::factory( $title ); |
1189 | 1194 | $page->doEdit( $text, '', EDIT_NEW ); |
1190 | 1195 | |
1191 | 1196 | $wgCapitalLinks = $oldCapitalLinks; |