Add wgAllowExternalImages option to parser tests.
authorC. Scott Ananian <cscott@cscott.net>
Wed, 10 Jul 2013 22:10:14 +0000 (18:10 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Wed, 10 Jul 2013 22:13:20 +0000 (18:13 -0400)
This allows us to test whether the parser properly respects the
$wgAllowExternalImages option.

I also renamed the 'rawhtml' option to wgRawHtml so that parser test
options which set wiki configuration variables have consistent names.

Bug: 51092
Change-Id: I6c453b3e366cf775d8eef2dcbde09fcfa7027125

tests/parser/parserTest.inc
tests/parser/parserTests.txt
tests/phpunit/includes/parser/NewParserTest.php

index 4efd708..0469138 100644 (file)
@@ -728,7 +728,7 @@ class ParserTest {
                        'wgSitename' => 'MediaWiki',
                        'wgLanguageCode' => $lang,
                        'wgDBprefix' => $this->db->getType() != 'oracle' ? 'parsertest_' : 'pt_',
-                       'wgRawHtml' => isset( $opts['rawhtml'] ),
+                       'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
                        'wgLang' => null,
                        'wgContLang' => null,
                        'wgNamespacesWithSubpages' => array( 0 => isset( $opts['subpage'] ) ),
@@ -741,7 +741,7 @@ class ParserTest {
                        'wgSVGConverter' => 'null',
                        'wgSVGConverters' => array( 'null' => 'echo "1">$output' ),
                        'wgLocaltimezone' => 'UTC',
-                       'wgAllowExternalImages' => true,
+                       'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
                        'wgUseTidy' => false,
                        'wgDefaultLanguageVariant' => $variant,
                        'wgVariantArticlePath' => false,
index 478b348..4a8802b 100644 (file)
 # comment       run through Linker::formatComment() instead of main parser
 # local         format section links in edit comment text as local links
 #
+# You can also set the following parser properties via test options:
+#  wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
+#  wgLinkHolderBatchSize, wgRawHtml
+#
 # For testing purposes, temporary articles can created:
 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
 # where '/' denotes a newline.
@@ -2751,6 +2755,17 @@ External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
 </p>
 !! end
 
+!! test
+External image (when not allowed)
+!! options
+wgAllowExternalImages=0
+!! input
+External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
+!! result
+<p>External image: <a rel="nofollow" class="external free" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png">http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a>
+</p>
+!! end
+
 !! test
 Link to non-http image, no img tag
 !! input
@@ -12238,7 +12253,7 @@ Images with the "|" character in the comment
 !! test
 HTML with raw HTML ($wgRawHtml==true)
 !! options
-rawhtml
+wgRawHtml=1
 !! input
 <html><script>alert(1);</script></html>
 !! result
index 54c7fb5..9551b2f 100644 (file)
@@ -317,8 +317,9 @@ class NewParserTest extends MediaWikiTestCase {
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgLanguageCode' => $lang,
                        'wgDBprefix' => $this->db->getType() != 'oracle' ? 'unittest_' : 'ut_',
-                       'wgRawHtml' => isset( $opts['rawhtml'] ),
+                       'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
                        'wgNamespacesWithSubpages' => array( NS_MAIN => isset( $opts['subpage'] ) ),
+                       'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
                        'wgMaxTocLevel' => $maxtoclevel,
                        'wgUseTeX' => isset( $opts['math'] ) || isset( $opts['texvc'] ),
                        'wgMathDirectory' => $uploadDir . '/math',