r5476 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5475‎ | r5476 | r5477 >
Date:21:49, 24 September 2004
Author:wmahan
Status:old
Tags:
Comment:
Add an option for setting the title; add test for interlanguage links;
remove dupliate test
Modified paths:
  • /trunk/phase3/maintenance/parserTests.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.sql (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -8,7 +8,10 @@
99 # (default) generate HTML output
1010 # pst apply pre-save transform
1111 # msg apply message transform
 12+# cat add category links
 13+# ill add inter-language links
1214 # subpage enable subpages (disabled by default)
 15+# title=[[XXX]] run test using article title XXX
1316 #
1417 # Tests can be disabled with the '!!disabled' flag.
1518 #
@@ -686,31 +689,7 @@
687690 </p>
688691 !! end
689692
690 -!! article
691 -Category:MediaWiki User's Guide
692 -!! text
693 -blah
694 -!! endarticle
695 -
696693 !! test
697 -Link to category
698 -!! input
699 -[[:Category:MediaWiki User's Guide]]
700 -!! result
701 -<p><a href="https://www.mediawiki.org/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
702 -</p>
703 -!! end
704 -
705 -!! test
706 -Link to image page
707 -!! input
708 -[[:Image:Ncwikicol.png]]
709 -!! result
710 -<p><a href="https://www.mediawiki.org/wiki/Image:Ncwikicol.png" title="Image:Ncwikicol.png">Image:Ncwikicol.png</a>
711 -</p>
712 -!! end
713 -
714 -!! test
715694 Plain link to URL
716695 !! input
717696 [[http://www.example.org]]
@@ -1152,7 +1131,7 @@
11531132 ### Subpages
11541133 ###
11551134 !! article
1156 -Parser test/subpage
 1135+Subpage test/subpage
11571136 !! text
11581137 foo
11591138 !! endarticle
@@ -1160,22 +1139,22 @@
11611140 !! test
11621141 Subpage link
11631142 !! options
1164 -subpage
 1143+subpage title=[[Subpage test]]
11651144 !! input
11661145 [[/subpage]]
11671146 !! result
1168 -<p><a href="https://www.mediawiki.org/wiki/Parser_test/subpage" title="Parser test/subpage">/subpage</a>
 1147+<p><a href="https://www.mediawiki.org/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
11691148 </p>
11701149 !! end
11711150
11721151 !! test
11731152 Subpage noslash link
11741153 !! options
1175 -subpage
 1154+subpage title=[[Subpage test]]
11761155 !!input
11771156 [[/subpage/]]
11781157 !! result
1179 -<p><a href="https://www.mediawiki.org/wiki/Parser_test/subpage" title="Parser test/subpage">subpage</a>
 1158+<p><a href="https://www.mediawiki.org/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
11801159 </p>
11811160 !! end
11821161
@@ -1189,6 +1168,50 @@
11901169 </p>
11911170 !! end
11921171
 1172+###
 1173+### Categories
 1174+###
 1175+!! article
 1176+Category:MediaWiki User's Guide
 1177+!! text
 1178+blah
 1179+!! endarticle
 1180+
 1181+!! test
 1182+Link to category
 1183+!! input
 1184+[[:Category:MediaWiki User's Guide]]
 1185+!! result
 1186+<p><a href="https://www.mediawiki.org/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
 1187+</p>
 1188+!! end
 1189+
 1190+!! test
 1191+Simple category
 1192+!! options
 1193+cat
 1194+!! input
 1195+[[Category: MediaWiki User's Guide]]
 1196+!! result
 1197+<a href="https://www.mediawiki.org/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
 1198+!! end
 1199+
 1200+###
 1201+### Inter-language links
 1202+###
 1203+!! test
 1204+Inter-language links
 1205+!! options
 1206+ill
 1207+!! input
 1208+[[es:Alimento]]
 1209+[[fr:Nourriture]]
 1210+[[zh:&#39135;&#21697;]]
 1211+!! result
 1212+es:Alimento fr:Nourriture zh:食品
 1213+!! end
 1214+
 1215+
11931216 TODO:
11941217 more images
11951218 more tables
Index: trunk/phase3/maintenance/parserTests.sql
@@ -285,8 +285,9 @@
286286 KEY page_time (log_namespace, log_title, log_timestamp)
287287 );
288288
289 -INSERT INTO parsertestinterwiki VALUES('MeatBall',
290 - 'http://www.usemod.com/cgi-bin/mb.pl?$1',
291 - 0
292 -);
 289+INSERT INTO parsertestinterwiki (iw_prefix,iw_url,iw_local) VALUES
 290+ ('MeatBall','http://www.usemod.com/cgi-bin/mb.pl?$1',0),
 291+ ('es','http://es.wikipedia.org/wiki/$1',1),
 292+ ('fr','http://fr.wikipedia.org/wiki/$1',1),
 293+ ('zh','http://zh.wikipedia.org/wiki/$1',1);
293294
Index: trunk/phase3/maintenance/parserTests.php
@@ -189,8 +189,15 @@
190190 $options->setUseTex(true);
191191 }
192192
 193+ if (preg_match('/title=\[\[(.*)\]\]/', $opts, $m)) {
 194+ $titleText = $m[1];
 195+ }
 196+ else {
 197+ $titleText = 'Parser test';
 198+ }
 199+
193200 $parser =& new Parser();
194 - $title =& Title::makeTitle( NS_MAIN, 'Parser_test' );
 201+ $title =& Title::makeTitle( NS_MAIN, $titleText );
195202
196203 if (preg_match('/pst/i', $opts)) {
197204 $out = $parser->preSaveTransform( $input, $title, $user, $options );
@@ -205,12 +212,12 @@
206213 $op = new OutputPage();
207214 $op->replaceLinkHolders($out);
208215
209 - #if (preg_match('/ill/i', $opts)) {
210 - # $out .= $output->getLanguageLinks();
211 - #}
212 - #if (preg_match('/cat/i', $opts)) {
213 - # $out .= $output->getCategoryLinks();
214 - #}
 216+ if (preg_match('/ill/i', $opts)) {
 217+ $out .= implode( ' ', $output->getLanguageLinks() );
 218+ }
 219+ if (preg_match('/cat/i', $opts)) {
 220+ $out .= implode( ' ', $output->getCategoryLinks() );
 221+ }
215222
216223 if ($GLOBALS['wgUseTidy']) {
217224 $result = Parser::tidy($result);

Status & tagging log