Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / includes / GlobalFunctions / wfThumbIsStandardTest.php
blob9d9815b79845e2b6fa6a9273d5587761cd2acb2b
1 <?php
3 /**
4 * @group GlobalFunctions
5 * @covers ::wfThumbIsStandard
6 */
7 class WfThumbIsStandardTest extends MediaWikiTestCase {
9 protected function setUp() {
10 parent::setUp();
12 $this->setMwGlobals( [
13 'wgThumbLimits' => [
14 100,
15 401
17 'wgImageLimits' => [
18 [ 300, 225 ],
19 [ 800, 600 ],
21 ] );
24 public static function provideThumbParams() {
25 return [
26 // Thumb limits
28 'Standard thumb width',
29 true,
30 [ 'width' => 100 ],
33 'Standard thumb width',
34 true,
35 [ 'width' => 401 ],
37 // wfThumbIsStandard should match Linker::processResponsiveImages
38 // in its rounding behaviour.
40 'Standard thumb width (HiDPI 1.5x) - incorrect rounding',
41 false,
42 [ 'width' => 601 ],
45 'Standard thumb width (HiDPI 1.5x)',
46 true,
47 [ 'width' => 602 ],
50 'Standard thumb width (HiDPI 2x)',
51 true,
52 [ 'width' => 802 ],
55 'Non-standard thumb width',
56 false,
57 [ 'width' => 300 ],
59 // Image limits
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',
64 true,
65 [ 'width' => 250, 'height' => 225 ],
68 'Standard image width/height pair',
69 true,
70 [ 'width' => 667, 'height' => 600 ],
73 'Standard image width where image does not fit aspect ratio',
74 false,
75 [ 'width' => 300 ],
78 'Implicit width from image width/height pair aspect ratio fit',
79 true,
80 // 2000x1800 fit inside 300x225 makes w=250
81 [ 'width' => 250 ],
84 'Height-only is always non-standard',
85 false,
86 [ 'height' => 225 ],
91 /**
92 * @dataProvider provideThumbParams
94 public function testIsStandard( $message, $expected, $params ) {
95 $this->setService( 'MediaHandlerFactory', new MockMediaHandlerFactory() );
96 $this->assertSame(
97 $expected,
98 wfThumbIsStandard( new FakeDimensionFile( [ 2000, 1800 ] ), $params ),
99 $message