3 use MediaWiki\MediaWikiServices
;
6 * @group GlobalFunctions
7 * @covers ::wfThumbIsStandard
9 class WfThumbIsStandardTest
extends MediaWikiTestCase
{
11 protected function setUp() {
14 $this->setMwGlobals( [
26 public static function provideThumbParams() {
30 'Standard thumb width',
35 'Standard thumb width',
39 // wfThumbIsStandard should match Linker::processResponsiveImages
40 // in its rounding behaviour.
42 'Standard thumb width (HiDPI 1.5x) - incorrect rounding',
47 'Standard thumb width (HiDPI 1.5x)',
52 'Standard thumb width (HiDPI 2x)',
57 'Non-standard thumb width',
62 // Note: Image limits are measured as pairs. Individual values
63 // may be non-standard based on the aspect ratio.
65 'Standard image width/height pair',
67 [ 'width' => 250, 'height' => 225 ],
70 'Standard image width/height pair',
72 [ 'width' => 667, 'height' => 600 ],
75 'Standard image width where image does not fit aspect ratio',
80 'Implicit width from image width/height pair aspect ratio fit',
82 // 2000x1800 fit inside 300x225 makes w=250
86 'Height-only is always non-standard',
94 * @dataProvider provideThumbParams
96 public function testIsStandard( $message, $expected, $params ) {
97 $handlers = MediaWikiServices
::getInstance()->getMainConfig()->get( 'ParserTestMediaHandlers' );
98 $this->setService( 'MediaHandlerFactory', new MediaHandlerFactory( $handlers ) );
101 wfThumbIsStandard( new FakeDimensionFile( [ 2000, 1800 ], 'image/jpeg' ), $params ),