4 * @group GlobalFunctions
5 * @covers ::wfThumbIsStandard
7 class WfThumbIsStandardTest
extends MediaWikiTestCase
{
9 protected function setUp() {
12 $this->setMwGlobals( array(
13 'wgThumbLimits' => array(
17 'wgImageLimits' => array(
21 'wgMediaHandlers' => array(
22 'unknown/unknown' => 'MockBitmapHandler',
27 public static function provideThumbParams() {
31 'Standard thumb width',
33 array( 'width' => 100 ),
36 'Standard thumb width',
38 array( 'width' => 401 ),
40 // wfThumbIsStandard should match Linker::processResponsiveImages
41 // in its rounding behaviour.
43 'Standard thumb width (HiDPI 1.5x) - incorrect rounding',
45 array( 'width' => 601 ),
48 'Standard thumb width (HiDPI 1.5x)',
50 array( 'width' => 602 ),
53 'Standard thumb width (HiDPI 2x)',
55 array( 'width' => 802 ),
58 'Non-standard thumb width',
60 array( 'width' => 300 ),
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 array( 'width' => 250, 'height' => 225 ),
71 'Standard image width/height pair',
73 array( 'width' => 667, 'height' => 600 ),
76 'Standard image width where image does not fit aspect ratio',
78 array( 'width' => 300 ),
81 'Implicit width from image width/height pair aspect ratio fit',
83 // 2000x1800 fit inside 300x225 makes w=250
84 array( 'width' => 250 ),
87 'Height-only is always non-standard',
89 array( 'height' => 225 ),
95 * @dataProvider provideThumbParams
97 public function testIsStandard( $message, $expected, $params ) {
100 wfThumbIsStandard( new FakeDimensionFile( array( 2000, 1800 ) ), $params ),