X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fmedia%2FExifRotationTest.php;h=5ae1763596dbff7a33ccd489f32836459a1e03d9;hb=50f1de243986a1d006fb4500fb19e5fa88cce336;hp=f0bd42a078a06282b90530ed61aaa8735022545f;hpb=ab29cc0ec608f490cbf4bc8e4c1c0e1d11822565;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php index f0bd42a078..5ae1763596 100644 --- a/tests/phpunit/includes/media/ExifRotationTest.php +++ b/tests/phpunit/includes/media/ExifRotationTest.php @@ -15,10 +15,10 @@ class ExifRotationTest extends MediaWikiMediaTestCase { $this->handler = new BitmapHandler(); - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgShowEXIF' => true, 'wgEnableAutoRotation' => true, - ) ); + ] ); } /** @@ -67,14 +67,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 +106,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 +172,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 +211,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 +250,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 ] + ], + ]; } }