4 * @group GlobalFunctions
5 * @covers ::wfThumbIsStandard
7 class WfThumbIsStandardTest
extends MediaWikiTestCase
{
9 protected function setUp() {
12 $this->setMwGlobals( [
24 public static function provideThumbParams() {
28 'Standard thumb width',
33 'Standard thumb width',
37 // wfThumbIsStandard should match Linker::processResponsiveImages
38 // in its rounding behaviour.
40 'Standard thumb width (HiDPI 1.5x) - incorrect rounding',
45 'Standard thumb width (HiDPI 1.5x)',
50 'Standard thumb width (HiDPI 2x)',
55 'Non-standard thumb width',
60 // Note: Image limits are measured as pairs. Individual values
61 // may be non-standard based on the aspect ratio.
63 'Standard image width/height pair',
65 [ 'width' => 250, 'height' => 225 ],
68 'Standard image width/height pair',
70 [ 'width' => 667, 'height' => 600 ],
73 'Standard image width where image does not fit aspect ratio',
78 'Implicit width from image width/height pair aspect ratio fit',
80 // 2000x1800 fit inside 300x225 makes w=250
84 'Height-only is always non-standard',
92 * @dataProvider provideThumbParams
94 public function testIsStandard( $message, $expected, $params ) {
95 $this->setService( 'MediaHandlerFactory', new MockMediaHandlerFactory() );
98 wfThumbIsStandard( new FakeDimensionFile( [ 2000, 1800 ] ), $params ),