Merge "Revision: Handle all return values of Title::newFromId"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / ExifRotationTest.php
index f0bd42a..fff101f 100644 (file)
@@ -5,20 +5,23 @@
  * @group Media
  * @group medium
  *
- * @todo covers tags
+ * @covers BitmapHandler
  */
 class ExifRotationTest extends MediaWikiMediaTestCase {
 
+       /** @var BitmapHandler */
+       private $handler;
+
        protected function setUp() {
                parent::setUp();
                $this->checkPHPExtension( 'exif' );
 
                $this->handler = new BitmapHandler();
 
-               $this->setMwGlobals( array(
+               $this->setMwGlobals( [
                        'wgShowEXIF' => true,
                        'wgEnableAutoRotation' => true,
-               ) );
+               ] );
        }
 
        /**
@@ -67,14 +70,14 @@ class ExifRotationTest extends MediaWikiMediaTestCase {
                }
                foreach ( $thumbs as $size => $out ) {
                        if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) {
-                               $params = array(
+                               $params = [
                                        'width' => $matches[1],
-                               );
+                               ];
                        } elseif ( preg_match( '/^(\d+)x(\d+)px$/', $size, $matches ) ) {
-                               $params = array(
+                               $params = [
                                        'width' => $matches[1],
                                        'height' => $matches[2]
-                               );
+                               ];
                        } else {
                                throw new MWException( 'bogus test data format ' . $size );
                        }
@@ -106,36 +109,36 @@ class ExifRotationTest extends MediaWikiMediaTestCase {
        }
 
        public static function provideFiles() {
-               return array(
-                       array(
+               return [
+                       [
                                'landscape-plain.jpg',
                                'image/jpeg',
-                               array(
+                               [
                                        'width' => 1024,
                                        'height' => 768,
-                               ),
-                               array(
-                                       '800x600px' => array( 800, 600 ),
-                                       '9999x800px' => array( 1067, 800 ),
-                                       '800px' => array( 800, 600 ),
-                                       '600px' => array( 600, 450 ),
-                               )
-                       ),
-                       array(
+                               ],
+                               [
+                                       '800x600px' => [ 800, 600 ],
+                                       '9999x800px' => [ 1067, 800 ],
+                                       '800px' => [ 800, 600 ],
+                                       '600px' => [ 600, 450 ],
+                               ]
+                       ],
+                       [
                                'portrait-rotated.jpg',
                                'image/jpeg',
-                               array(
+                               [
                                        'width' => 768, // as rotated
                                        'height' => 1024, // as rotated
-                               ),
-                               array(
-                                       '800x600px' => array( 450, 600 ),
-                                       '9999x800px' => array( 600, 800 ),
-                                       '800px' => array( 800, 1067 ),
-                                       '600px' => array( 600, 800 ),
-                               )
-                       )
-               );
+                               ],
+                               [
+                                       '800x600px' => [ 450, 600 ],
+                                       '9999x800px' => [ 600, 800 ],
+                                       '800px' => [ 800, 1067 ],
+                                       '600px' => [ 600, 800 ],
+                               ]
+                       ]
+               ];
        }
 
        /**
@@ -172,14 +175,14 @@ class ExifRotationTest extends MediaWikiMediaTestCase {
 
                foreach ( $thumbs as $size => $out ) {
                        if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) {
-                               $params = array(
+                               $params = [
                                        'width' => $matches[1],
-                               );
+                               ];
                        } elseif ( preg_match( '/^(\d+)x(\d+)px$/', $size, $matches ) ) {
-                               $params = array(
+                               $params = [
                                        'width' => $matches[1],
                                        'height' => $matches[2]
-                               );
+                               ];
                        } else {
                                throw new MWException( 'bogus test data format ' . $size );
                        }
@@ -211,36 +214,36 @@ class ExifRotationTest extends MediaWikiMediaTestCase {
        }
 
        public static function provideFilesNoAutoRotate() {
-               return array(
-                       array(
+               return [
+                       [
                                'landscape-plain.jpg',
                                'image/jpeg',
-                               array(
+                               [
                                        'width' => 1024,
                                        'height' => 768,
-                               ),
-                               array(
-                                       '800x600px' => array( 800, 600 ),
-                                       '9999x800px' => array( 1067, 800 ),
-                                       '800px' => array( 800, 600 ),
-                                       '600px' => array( 600, 450 ),
-                               )
-                       ),
-                       array(
+                               ],
+                               [
+                                       '800x600px' => [ 800, 600 ],
+                                       '9999x800px' => [ 1067, 800 ],
+                                       '800px' => [ 800, 600 ],
+                                       '600px' => [ 600, 450 ],
+                               ]
+                       ],
+                       [
                                'portrait-rotated.jpg',
                                'image/jpeg',
-                               array(
+                               [
                                        'width' => 1024, // since not rotated
                                        'height' => 768, // since not rotated
-                               ),
-                               array(
-                                       '800x600px' => array( 800, 600 ),
-                                       '9999x800px' => array( 1067, 800 ),
-                                       '800px' => array( 800, 600 ),
-                                       '600px' => array( 600, 450 ),
-                               )
-                       )
-               );
+                               ],
+                               [
+                                       '800x600px' => [ 800, 600 ],
+                                       '9999x800px' => [ 1067, 800 ],
+                                       '800px' => [ 800, 600 ],
+                                       '600px' => [ 600, 450 ],
+                               ]
+                       ]
+               ];
        }
 
        const TEST_WIDTH = 100;
@@ -250,31 +253,31 @@ class ExifRotationTest extends MediaWikiMediaTestCase {
         * @dataProvider provideBitmapExtractPreRotationDimensions
         */
        public function testBitmapExtractPreRotationDimensions( $rotation, $expected ) {
-               $result = $this->handler->extractPreRotationDimensions( array(
+               $result = $this->handler->extractPreRotationDimensions( [
                        'physicalWidth' => self::TEST_WIDTH,
                        'physicalHeight' => self::TEST_HEIGHT,
-               ), $rotation );
+               ], $rotation );
                $this->assertEquals( $expected, $result );
        }
 
        public static function provideBitmapExtractPreRotationDimensions() {
-               return array(
-                       array(
+               return [
+                       [
                                0,
-                               array( self::TEST_WIDTH, self::TEST_HEIGHT )
-                       ),
-                       array(
+                               [ self::TEST_WIDTH, self::TEST_HEIGHT ]
+                       ],
+                       [
                                90,
-                               array( self::TEST_HEIGHT, self::TEST_WIDTH )
-                       ),
-                       array(
+                               [ self::TEST_HEIGHT, self::TEST_WIDTH ]
+                       ],
+                       [
                                180,
-                               array( self::TEST_WIDTH, self::TEST_HEIGHT )
-                       ),
-                       array(
+                               [ self::TEST_WIDTH, self::TEST_HEIGHT ]
+                       ],
+                       [
                                270,
-                               array( self::TEST_HEIGHT, self::TEST_WIDTH )
-                       ),
-               );
+                               [ self::TEST_HEIGHT, self::TEST_WIDTH ]
+                       ],
+               ];
        }
 }