bca4b55a5f1584936a397a4e0291a22b3ba5d8e1
3 class BitmapScalingTest
extends MediaWikiTestCase
{
5 * @dataProvider provideNormaliseParams
7 function testNormaliseParams( $fileDimensions, $expectedParams, $params, $msg ) {
8 $file = new FakeDimensionFile( $fileDimensions );
9 $handler = new BitmapHandler
;
10 $handler->normaliseParams( $file, $params );
11 $this->assertEquals( $expectedParams, $params, $msg );
14 function provideNormaliseParams() {
16 /* Regular resize operations */
20 'width' => 512, 'height' => 384,
21 'physicalWidth' => 512, 'physicalHeight' => 384,
24 array( 'width' => 512 ),
25 'Resizing with width set',
30 'width' => 512, 'height' => 384,
31 'physicalWidth' => 512, 'physicalHeight' => 384,
34 array( 'width' => 512, 'height' => 768 ),
35 'Resizing with height set too high',
40 'width' => 512, 'height' => 384,
41 'physicalWidth' => 512, 'physicalHeight' => 384,
44 array( 'width' => 1024, 'height' => 384 ),
45 'Resizing with height set',
48 /* Very tall images */
52 'width' => 5, 'height' => 1,
53 'physicalWidth' => 5, 'physicalHeight' => 1,
56 array( 'width' => 5 ),
63 'width' => 1, 'height' => 10,
64 'physicalWidth' => 1, 'physicalHeight' => 10,
67 array( 'width' => 1 ),
73 'width' => 1, 'height' => 5,
74 'physicalWidth' => 1, 'physicalHeight' => 10,
77 array( 'width' => 10, 'height' => 5 ),
78 'Very high image with height set',
84 class FakeDimensionFile
extends File
{
85 public function __construct( $dimensions ) {
86 parent
::__construct( Title
::makeTitle( NS_FILE
, 'Test' ), null );
88 $this->dimensions
= $dimensions;
90 public function getWidth( $page = 1 ) {
91 return $this->dimensions
[0];
93 public function getHeight( $page = 1 ) {
94 return $this->dimensions
[1];