4 * @group GlobalFunctions
5 * @covers ::wfThumbIsStandard
7 class WfThumbIsStandardTest
extends MediaWikiTestCase
{
9 protected function setUp() {
12 $this->setMwGlobals( [
21 'wgMediaHandlers' => [
22 'unknown/unknown' => 'MockBitmapHandler',
27 public static function provideThumbParams() {
31 'Standard thumb width',
36 'Standard thumb width',
40 // wfThumbIsStandard should match Linker::processResponsiveImages
41 // in its rounding behaviour.
43 'Standard thumb width (HiDPI 1.5x) - incorrect rounding',
48 'Standard thumb width (HiDPI 1.5x)',
53 'Standard thumb width (HiDPI 2x)',
58 'Non-standard thumb width',
63 // Note: Image limits are measured as pairs. Individual values
64 // may be non-standard based on the aspect ratio.
66 'Standard image width/height pair',
68 [ 'width' => 250, 'height' => 225 ],
71 'Standard image width/height pair',
73 [ 'width' => 667, 'height' => 600 ],
76 'Standard image width where image does not fit aspect ratio',
81 'Implicit width from image width/height pair aspect ratio fit',
83 // 2000x1800 fit inside 300x225 makes w=250
87 'Height-only is always non-standard',
95 * @dataProvider provideThumbParams
97 public function testIsStandard( $message, $expected, $params ) {
100 wfThumbIsStandard( new FakeDimensionFile( [ 2000, 1800 ] ), $params ),