3 use MediaWiki\MainConfigNames
;
4 use Psr\Log\NullLogger
;
7 * @group GlobalFunctions
8 * @covers ::wfThumbIsStandard
10 class WfThumbIsStandardTest
extends MediaWikiIntegrationTestCase
{
12 protected function setUp(): void
{
15 $this->overrideConfigValues( [
16 MainConfigNames
::ThumbLimits
=> [
20 MainConfigNames
::ImageLimits
=> [
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 ) {
98 $handlers = $this->getConfVar( MainConfigNames
::ParserTestMediaHandlers
);
100 'MediaHandlerFactory',
101 new MediaHandlerFactory( new NullLogger(), $handlers )
105 wfThumbIsStandard( new FakeDimensionFile( [ 2000, 1800 ], 'image/jpeg' ), $params ),