diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:31:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:58:39 +0200 |
commit | f6d65e533c62f6deb21342d4901ece24497b433e (patch) | |
tree | f28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/phpunit/includes/GlobalFunctions/wfThumbIsStandardTest.php | |
parent | c27b2e832fe25651ef2410fae85b41072aae7519 (diff) |
Update to MediaWiki 1.25.1
Diffstat (limited to 'tests/phpunit/includes/GlobalFunctions/wfThumbIsStandardTest.php')
-rw-r--r-- | tests/phpunit/includes/GlobalFunctions/wfThumbIsStandardTest.php | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/phpunit/includes/GlobalFunctions/wfThumbIsStandardTest.php b/tests/phpunit/includes/GlobalFunctions/wfThumbIsStandardTest.php new file mode 100644 index 00000000..448250a6 --- /dev/null +++ b/tests/phpunit/includes/GlobalFunctions/wfThumbIsStandardTest.php @@ -0,0 +1,104 @@ +<?php + +/** + * @group GlobalFunctions + * @covers ::wfThumbIsStandard + */ +class WfThumbIsStandardTest extends MediaWikiTestCase { + + protected function setUp() { + parent::setUp(); + + $this->setMwGlobals( array( + 'wgThumbLimits' => array( + 100, + 401 + ), + 'wgImageLimits' => array( + array( 300, 225 ), + array( 800, 600 ), + ), + 'wgMediaHandlers' => array( + 'unknown/unknown' => 'MockBitmapHandler', + ), + ) ); + } + + public static function provideThumbParams() { + return array( + // Thumb limits + array( + 'Standard thumb width', + true, + array( 'width' => 100 ), + ), + array( + 'Standard thumb width', + true, + array( 'width' => 401 ), + ), + // wfThumbIsStandard should match Linker::processResponsiveImages + // in its rounding behaviour. + array( + 'Standard thumb width (HiDPI 1.5x) - incorrect rounding', + false, + array( 'width' => 601 ), + ), + array( + 'Standard thumb width (HiDPI 1.5x)', + true, + array( 'width' => 602 ), + ), + array( + 'Standard thumb width (HiDPI 2x)', + true, + array( 'width' => 802 ), + ), + array( + 'Non-standard thumb width', + false, + array( 'width' => 300 ), + ), + // Image limits + // Note: Image limits are measured as pairs. Individual values + // may be non-standard based on the aspect ratio. + array( + 'Standard image width/height pair', + true, + array( 'width' => 250, 'height' => 225 ), + ), + array( + 'Standard image width/height pair', + true, + array( 'width' => 667, 'height' => 600 ), + ), + array( + 'Standard image width where image does not fit aspect ratio', + false, + array( 'width' => 300 ), + ), + array( + 'Implicit width from image width/height pair aspect ratio fit', + true, + // 2000x1800 fit inside 300x225 makes w=250 + array( 'width' => 250 ), + ), + array( + 'Height-only is always non-standard', + false, + array( 'height' => 225 ), + ), + ); + } + + /** + * @dataProvider provideThumbParams + */ + public function testIsStandard( $message, $expected, $params ) { + $this->assertSame( + $expected, + wfThumbIsStandard( new FakeDimensionFile( array( 2000, 1800 ) ), $params ), + $message + ); + } +} |