From 3f301cefeedf3c72d6036f941f09c9b19782d347 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 20 Sep 2011 19:39:17 +0000 Subject: [PATCH] Further tweaks to r96687, r90016, r97398 etc tests: actually produce a thumbnail and check its size as well. Confirms that we're handling bounding boxes incorrectly. --- .../includes/media/ExifRotationTest.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php index 74f5390cde..75e966498b 100644 --- a/tests/phpunit/includes/media/ExifRotationTest.php +++ b/tests/phpunit/includes/media/ExifRotationTest.php @@ -9,6 +9,11 @@ class ExifRotationTest extends MediaWikiTestCase { parent::setUp(); $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; $this->handler = new BitmapHandler(); + $this->repo = new FSRepo(array( + 'name' => 'temp', + 'directory' => wfTempDir() . '/exif-test-' . time(), + 'url' => 'http://localhost/thumbtest' + )); if ( !wfDl( 'exif' ) ) { $this->markTestSkipped( "This test needs the exif extension." ); } @@ -31,6 +36,29 @@ class ExifRotationTest extends MediaWikiTestCase { $this->assertEquals( $file->getHeight(), $info['height'], "$name: height check" ); } + /** + * + * @dataProvider providerFiles + */ + function testRotationRendering( $name, $type, $info ) { + $file = $this->localFile( $name, $type ); + $thumb = $file->transform( array( + 'width' => 800, + 'height' => 600, + ), File::RENDER_NOW ); + + $this->assertEquals( $thumb->getWidth(), $info['thumbWidth'], "$name: thumb reported width check" ); + $this->assertEquals( $thumb->getHeight(), $info['thumbHeight'], "$name: thumb reported height check" ); + + $gis = getimagesize( $thumb->getPath() ); + $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: thumb actual width check"); + $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: thumb actual height check"); + } + + private function localFile( $name, $type ) { + return new UnregisteredLocalFile( false, $this->repo, $this->filePath . $name, $type ); + } + function providerFiles() { return array( array( @@ -39,6 +67,8 @@ class ExifRotationTest extends MediaWikiTestCase { array( 'width' => 1024, 'height' => 768, + 'thumbWidth' => 800, + 'thumbHeight' => 600, ) ), array( @@ -47,6 +77,8 @@ class ExifRotationTest extends MediaWikiTestCase { array( 'width' => 768, // as rotated 'height' => 1024, // as rotated + 'thumbWidth' => 450, + 'thumbHeight' => 600, ) ) ); -- 2.20.1