mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-12 01:15:21 +00:00
Merge "Add more integrated parser test"
This commit is contained in:
commit
69f7d0d2f8
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
|
46
tests/parser/pageImagesParserTests.txt
Normal file
46
tests/parser/pageImagesParserTests.txt
Normal 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&action=edit&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
|
Loading…
Reference in a new issue