Remove messages.inc, rebuildLanguage.php, writeMessagesArray.inc
[mediawiki.git] / tests / phpunit / includes / media / BitmapScalingTest.php
blob9395b660711b42ab769f8c49a7c9665fe235835d
1 <?php
3 class BitmapScalingTest extends MediaWikiTestCase {
5 protected function setUp() {
6 parent::setUp();
8 $this->setMwGlobals( array(
9 'wgMaxImageArea' => 1.25e7, // 3500x3500
10 'wgCustomConvertCommand' => 'dummy', // Set so that we don't get client side rendering
11 ) );
14 /**
15 * @dataProvider provideNormaliseParams
16 * @covers BitmapHandler::normaliseParams
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 );
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,
36 array( 'width' => 512 ),
37 'Resizing with width set',
39 array(
40 array( 1024, 768 ),
41 array(
42 'width' => 512, 'height' => 384,
43 'physicalWidth' => 512, 'physicalHeight' => 384,
44 'page' => 1,
46 array( 'width' => 512, 'height' => 768 ),
47 'Resizing with height set too high',
49 array(
50 array( 1024, 768 ),
51 array(
52 'width' => 512, 'height' => 384,
53 'physicalWidth' => 512, 'physicalHeight' => 384,
54 'page' => 1,
56 array( 'width' => 1024, 'height' => 384 ),
57 'Resizing with height set',
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,
68 array( 'width' => 5 ),
69 'Very wide image',
72 array(
73 array( 100, 1000 ),
74 array(
75 'width' => 1, 'height' => 10,
76 'physicalWidth' => 1, 'physicalHeight' => 10,
77 'page' => 1,
79 array( 'width' => 1 ),
80 'Very high image',
82 array(
83 array( 100, 1000 ),
84 array(
85 'width' => 1, 'height' => 5,
86 'physicalWidth' => 1, 'physicalHeight' => 10,
87 'page' => 1,
89 array( 'width' => 10, 'height' => 5 ),
90 'Very high image with height set',
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,
100 array( 'width' => 5000 ),
101 'Bigger than max image size but doesn\'t need scaling',
107 * @covers BitmapHandler::doTransform
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 ) ) );
118 * @covers BitmapHandler::doTransform
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 ) ) );
130 * @covers BitmapHandler::getImageArea
132 public function testImageArea() {
133 $file = new FakeDimensionFile( array( 7, 9 ) );
134 $handler = new BitmapHandler;
135 $this->assertEquals( 63, $handler->getImageArea( $file ) );