MediaWiki  1.23.2
BitmapScalingTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5  protected function setUp() {
6  parent::setUp();
7 
8  $this->setMwGlobals( array(
9  'wgMaxImageArea' => 1.25e7, // 3500x3500
10  'wgCustomConvertCommand' => 'dummy', // Set so that we don't get client side rendering
11  ) );
12  }
13 
18  public function testNormaliseParams( $fileDimensions, $expectedParams, $params, $msg ) {
19  $file = new FakeDimensionFile( $fileDimensions );
20  $handler = new BitmapHandler;
21  $valid = $handler->normaliseParams( $file, $params );
22  $this->assertTrue( $valid );
23  $this->assertEquals( $expectedParams, $params, $msg );
24  }
25 
26  public static function provideNormaliseParams() {
27  return array(
28  /* Regular resize operations */
29  array(
30  array( 1024, 768 ),
31  array(
32  'width' => 512, 'height' => 384,
33  'physicalWidth' => 512, 'physicalHeight' => 384,
34  'page' => 1,
35  ),
36  array( 'width' => 512 ),
37  'Resizing with width set',
38  ),
39  array(
40  array( 1024, 768 ),
41  array(
42  'width' => 512, 'height' => 384,
43  'physicalWidth' => 512, 'physicalHeight' => 384,
44  'page' => 1,
45  ),
46  array( 'width' => 512, 'height' => 768 ),
47  'Resizing with height set too high',
48  ),
49  array(
50  array( 1024, 768 ),
51  array(
52  'width' => 512, 'height' => 384,
53  'physicalWidth' => 512, 'physicalHeight' => 384,
54  'page' => 1,
55  ),
56  array( 'width' => 1024, 'height' => 384 ),
57  'Resizing with height set',
58  ),
59 
60  /* Very tall images */
61  array(
62  array( 1000, 100 ),
63  array(
64  'width' => 5, 'height' => 1,
65  'physicalWidth' => 5, 'physicalHeight' => 1,
66  'page' => 1,
67  ),
68  array( 'width' => 5 ),
69  'Very wide image',
70  ),
71 
72  array(
73  array( 100, 1000 ),
74  array(
75  'width' => 1, 'height' => 10,
76  'physicalWidth' => 1, 'physicalHeight' => 10,
77  'page' => 1,
78  ),
79  array( 'width' => 1 ),
80  'Very high image',
81  ),
82  array(
83  array( 100, 1000 ),
84  array(
85  'width' => 1, 'height' => 5,
86  'physicalWidth' => 1, 'physicalHeight' => 10,
87  'page' => 1,
88  ),
89  array( 'width' => 10, 'height' => 5 ),
90  'Very high image with height set',
91  ),
92  /* Max image area */
93  array(
94  array( 4000, 4000 ),
95  array(
96  'width' => 5000, 'height' => 5000,
97  'physicalWidth' => 4000, 'physicalHeight' => 4000,
98  'page' => 1,
99  ),
100  array( 'width' => 5000 ),
101  'Bigger than max image size but doesn\'t need scaling',
102  ),
103  );
104  }
105 
109  public function testTooBigImage() {
110  $file = new FakeDimensionFile( array( 4000, 4000 ) );
111  $handler = new BitmapHandler;
112  $params = array( 'width' => '3700' ); // Still bigger than max size.
113  $this->assertEquals( 'TransformParameterError',
114  get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
115  }
116 
120  public function testTooBigMustRenderImage() {
121  $file = new FakeDimensionFile( array( 4000, 4000 ) );
122  $file->mustRender = true;
123  $handler = new BitmapHandler;
124  $params = array( 'width' => '5000' ); // Still bigger than max size.
125  $this->assertEquals( 'TransformParameterError',
126  get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
127  }
128 
132  public function testImageArea() {
133  $file = new FakeDimensionFile( array( 7, 9 ) );
134  $handler = new BitmapHandler;
135  $this->assertEquals( 63, $handler->getImageArea( $file ) );
136  }
137 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
BitmapScalingTest\testTooBigMustRenderImage
testTooBigMustRenderImage()
@covers BitmapHandler::doTransform
Definition: BitmapScalingTest.php:120
BitmapScalingTest\testTooBigImage
testTooBigImage()
@covers BitmapHandler::doTransform
Definition: BitmapScalingTest.php:109
BitmapScalingTest\testNormaliseParams
testNormaliseParams( $fileDimensions, $expectedParams, $params, $msg)
@dataProvider provideNormaliseParams @covers BitmapHandler::normaliseParams
Definition: BitmapScalingTest.php:18
$params
$params
Definition: styleTest.css.php:40
BitmapScalingTest\testImageArea
testImageArea()
@covers BitmapHandler::getImageArea
Definition: BitmapScalingTest.php:132
BitmapScalingTest\setUp
setUp()
Definition: BitmapScalingTest.php:5
BitmapScalingTest
Definition: BitmapScalingTest.php:3
BitmapHandler
Generic handler for bitmap images.
Definition: Bitmap.php:29
FakeDimensionFile
Definition: FakeDimensionFile.php:3
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
BitmapScalingTest\provideNormaliseParams
static provideNormaliseParams()
Definition: BitmapScalingTest.php:26
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
BitmapHandler\normaliseParams
normaliseParams( $image, &$params)
Definition: Bitmap.php:37