From: C. Scott Ananian Date: Wed, 19 Mar 2014 18:51:21 +0000 (-0400) Subject: Allow setting default thumb size in parser tests X-Git-Tag: 1.31.0-rc.0~16558^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=e784f96a56f147727a722b0426aace1f3da1d402 Allow setting default thumb size in parser tests The mediawiki default thumb size is 180px. The Parsoid default thumb size is 220px, to match the default thumb size for most WMF wikipedias (see https://bugzilla.wikimedia.org/show_bug.cgi?id=43336). This discrepancy leads to inconsistent image-related test output. Allow a test to set an explicit default thumb size with the 'thumbsize' option so that it is possible to write consistent tests. Change-Id: Ib764d1f1660a50caaf8f0ff245822d1d1a1d264e --- diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 65296d53d4..ef2f9c6076 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -787,6 +787,7 @@ class ParserTest { 'wgSVGConverters' => array( 'null' => 'echo "1">$output' ), 'wgLocaltimezone' => 'UTC', 'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ), + 'wgThumbLimits' => array( self::getOptionValue( 'thumbsize', $opts, 180 ) ), 'wgUseTidy' => false, 'wgDefaultLanguageVariant' => $variant, 'wgVariantArticlePath' => false, @@ -841,8 +842,10 @@ class ParserTest { $context = new RequestContext(); $GLOBALS['wgLang'] = $context->getLanguage(); $GLOBALS['wgOut'] = $context->getOutput(); + $GLOBALS['wgUser'] = $context->getUser(); - $GLOBALS['wgUser'] = new User(); + // We (re)set $wgThumbLimits to a single-element array above. + $context->getUser()->setOption( 'thumbsize', 0 ); global $wgHooks; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 0a2e87fcaa..9a0b3fb961 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -27,6 +27,7 @@ # comment run through Linker::formatComment() instead of main parser # local format section links in edit comment text as local links # notoc disable table of contents +# thumbsize=NNN set the default thumb size to NNNpx for this test # # You can also set the following parser properties via test options: # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel, @@ -9747,13 +9748,15 @@ Image with caption, bug 53312 #3 !! test Allow empty links in image captions (Bug 60753) +!! options +thumbsize=220 !! wikitext [[File:Foobar.jpg|thumb|Caption [[Link1]] [[]] [[Link2]] ]] !! html/php -
Caption Link1 [[]] Link2
+
Caption Link1 [[]] Link2
!! html/parsoid
Caption Link1 @@ -9832,6 +9835,8 @@ Image with multiple attributes from the same template !! test Image with link tails +!! options +thumbsize=220 !! wikitext 123[[File:Foobar.jpg]]456 123[[File:Foobar.jpg|right]]456 @@ -9840,7 +9845,7 @@ Image with link tails

123Foobar.jpg456

123
Foobar.jpg
456 -123
Foobar.jpg
456 +123
Foobar.jpg
456 !! html/parsoid

123456

@@ -9872,12 +9877,14 @@ Image with multiple widths -- use last !! test Image with multiple alignments -- use first (bug 48664) +!! options +thumbsize=220 !! wikitext [[File:Foobar.jpg|thumb|left|right|center|caption]] [[File:Foobar.jpg|middle|text-top|caption]] !! html/php -
caption
+
caption

caption

!! html/parsoid @@ -10033,11 +10040,12 @@ Image with link parameter (URL target) and unnamed parameter !! test Thumbnail image with link parameter !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb|link=http://example.com/|Title]] !! html/php -
Title
+
Title
!! html/parsoid
Title
@@ -10045,6 +10053,8 @@ parsoid=wt2html,wt2wt,html2html !! test Manually-specified thumbnail image +!! options +thumbsize=220 !! wikitext [[File:Foobar.jpg|thumb=Thumb.png|Title]] !! html/php @@ -10057,6 +10067,7 @@ Manually-specified thumbnail image !! test Manually-specified thumbnail image with explicit link to wiki page !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]] @@ -10070,6 +10081,7 @@ parsoid=wt2html,wt2wt,html2html !! test Manually-specified thumbnail image with explicit link to url !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]] @@ -10083,6 +10095,7 @@ parsoid=wt2html,wt2wt,html2html !! test Manually-specified thumbnail image with explicit no link !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]] @@ -10096,6 +10109,7 @@ parsoid=wt2html,wt2wt,html2html !! test Manually-specified thumbnail image with explicit link and alt text !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]] @@ -10311,10 +10325,12 @@ Frameless image caption with a free URL !! test Thumbnail image caption with a free URL +!! options +thumbsize=220 !! wikitext [[File:Foobar.jpg|thumb|http://example.com]] !! html/php - + !! html/parsoid
http://example.com
@@ -10323,11 +10339,12 @@ Thumbnail image caption with a free URL !! test Thumbnail image caption with a free URL and explicit alt !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]] !! html/php - + !! html/parsoid
Alteration
http://example.com
@@ -10547,12 +10564,13 @@ language=es !! test Localized image handling (2). !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html language=es !! wikitext [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]] !! html/php -
caption
+
caption
!! html/parsoid
caption
@@ -10561,11 +10579,12 @@ language=es !! test "border", "frameless" and "class" attributes on an image. !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|frameless|border|class=extra|caption]] !! html/php -

caption +

caption

!! html/parsoid

@@ -10575,6 +10594,7 @@ parsoid=wt2html,wt2wt,html2html !! test Invalid image attributes (bug 62500) !! options +thumbsize=220 parsoid=wt2html,wt2wt,html2html !! wikitext [[File:Foobar.jpg|thumb|float|left|caption]] @@ -10583,9 +10603,9 @@ parsoid=wt2html,wt2wt,html2html [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]] !! html/php -
caption
-
caption
-
caption
+
caption
+
caption
+
caption
!! html/parsoid
caption
caption
caption
diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index f75b254c3a..c6ded029e2 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -337,6 +337,7 @@ class NewParserTest extends MediaWikiTestCase { 'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ), 'wgNamespacesWithSubpages' => array( NS_MAIN => isset( $opts['subpage'] ) ), 'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ), + 'wgThumbLimits' => array( self::getOptionValue( 'thumbsize', $opts, 180 ) ), 'wgMaxTocLevel' => $maxtoclevel, 'wgUseTeX' => isset( $opts['math'] ) || isset( $opts['texvc'] ), 'wgMathDirectory' => $uploadDir . '/math', @@ -368,6 +369,9 @@ class NewParserTest extends MediaWikiTestCase { $settings['wgUser'] = $context->getUser(); $settings['wgRequest'] = $context->getRequest(); + // We (re)set $wgThumbLimits to a single-element array above. + $context->getUser()->setOption( 'thumbsize', 0 ); + foreach ( $settings as $var => $val ) { if ( array_key_exists( $var, $GLOBALS ) ) { $this->savedGlobals[$var] = $GLOBALS[$var];