From: C. Scott Ananian Date: Wed, 10 Jul 2013 22:10:14 +0000 (-0400) Subject: Add wgAllowExternalImages option to parser tests. X-Git-Tag: 1.31.0-rc.0~19049^2~1 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=64800d70923e5953aa0da8402314b0480c95cd33;p=lhc%2Fweb%2Fwiklou.git Add wgAllowExternalImages option to parser tests. 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 --- diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 4efd7082d0..0469138ec8 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -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, diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 478b3489c8..4a8802bc13 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -27,6 +27,10 @@ # 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

!! end +!! test +External image (when not allowed) +!! options +wgAllowExternalImages=0 +!! input +External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png +!! result +

External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png +

+!! 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 !! result diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 54c7fb57ac..9551b2f614 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -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',