Merge "Add more integrated parser test"

This commit is contained in:
jenkins-bot 2022-02-03 20:21:48 +00:00 committed by Gerrit Code Review
commit 69f7d0d2f8
3 changed files with 65 additions and 0 deletions

View file

@ -29,6 +29,7 @@
"InfoAction": "PageImages\\PageImages::onInfoAction",
"ParserAfterTidy": "PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserAfterTidy",
"ParserModifyImageHTML": "PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserModifyImageHTML",
"ParserTestGlobals": "PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserTestGlobals",
"SearchResultProvideThumbnail": "PageImages\\Hooks\\SearchResultProvideThumbnailHookHandler::onSearchResultProvideThumbnail",
"SpecialMobileEditWatchlist::images": "PageImages\\PageImages::onSpecialMobileEditWatchlistImages"
},

View file

@ -66,6 +66,24 @@ class ParserFileProcessingHookHandlers {
$handler->doParserAfterTidy( $parser, $text );
}
/**
* @param array &$globals
*/
public static function onParserTestGlobals( &$globals ) {
$globals += [
'wgPageImagesScores' => [
'width' => [
200 => 10,
1000 => 20
],
'position' => [],
'ratio' => [],
'galleryImageWidth' => []
],
'wgPageImagesLeadSectionOnly' => true
];
}
/**
* @param Parser $parser
* @param File $file

View file

@ -0,0 +1,46 @@
!! Version 2
!! test
PageImages with one image
!! options
property=page_image_free
!! wikitext
[[File:Foobar.jpg]]
!! html
<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
</p>
property[page_image_free]=Foobar.jpg
!! end
!! test
PageImages with two images
!! options
property=page_image_free
!! wikitext
[[File:Thumb.png]]
[[File:Foobar.jpg]]
!! html
<p><a href="/wiki/File:Thumb.png" class="image"><img alt="Thumb.png" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" /></a>
<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
</p>
property[page_image_free]=Foobar.jpg
!! end
!! test
PageImages with best excluded by wgPageImagesLeadSectionOnly
!! options
property=page_image_free
!! wikitext
[[File:Thumb.png]]
== Section ==
[[File:Foobar.jpg]]
!! html
<p><a href="/wiki/File:Thumb.png" class="image"><img alt="Thumb.png" src="http://example.com/images/e/ea/Thumb.png" decoding="async" width="135" height="135" /></a>
</p>
<h2><span class="mw-headline" id="Section">Section</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
</p>
property[page_image_free]=Thumb.png
!! end