Index: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php |
— | — | @@ -9,6 +9,11 @@ |
10 | 10 | parent::setUp(); |
11 | 11 | $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; |
12 | 12 | $this->handler = new BitmapHandler(); |
| 13 | + $this->repo = new FSRepo(array( |
| 14 | + 'name' => 'temp', |
| 15 | + 'directory' => wfTempDir() . '/exif-test-' . time(), |
| 16 | + 'url' => 'http://localhost/thumbtest' |
| 17 | + )); |
13 | 18 | if ( !wfDl( 'exif' ) ) { |
14 | 19 | $this->markTestSkipped( "This test needs the exif extension." ); |
15 | 20 | } |
— | — | @@ -31,6 +36,29 @@ |
32 | 37 | $this->assertEquals( $file->getHeight(), $info['height'], "$name: height check" ); |
33 | 38 | } |
34 | 39 | |
| 40 | + /** |
| 41 | + * |
| 42 | + * @dataProvider providerFiles |
| 43 | + */ |
| 44 | + function testRotationRendering( $name, $type, $info ) { |
| 45 | + $file = $this->localFile( $name, $type ); |
| 46 | + $thumb = $file->transform( array( |
| 47 | + 'width' => 800, |
| 48 | + 'height' => 600, |
| 49 | + ), File::RENDER_NOW ); |
| 50 | + |
| 51 | + $this->assertEquals( $thumb->getWidth(), $info['thumbWidth'], "$name: thumb reported width check" ); |
| 52 | + $this->assertEquals( $thumb->getHeight(), $info['thumbHeight'], "$name: thumb reported height check" ); |
| 53 | + |
| 54 | + $gis = getimagesize( $thumb->getPath() ); |
| 55 | + $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: thumb actual width check"); |
| 56 | + $this->assertEquals( $gis[0], $info['thumbWidth'], "$name: thumb actual height check"); |
| 57 | + } |
| 58 | + |
| 59 | + private function localFile( $name, $type ) { |
| 60 | + return new UnregisteredLocalFile( false, $this->repo, $this->filePath . $name, $type ); |
| 61 | + } |
| 62 | + |
35 | 63 | function providerFiles() { |
36 | 64 | return array( |
37 | 65 | array( |
— | — | @@ -39,6 +67,8 @@ |
40 | 68 | array( |
41 | 69 | 'width' => 1024, |
42 | 70 | 'height' => 768, |
| 71 | + 'thumbWidth' => 800, |
| 72 | + 'thumbHeight' => 600, |
43 | 73 | ) |
44 | 74 | ), |
45 | 75 | array( |
— | — | @@ -47,6 +77,8 @@ |
48 | 78 | array( |
49 | 79 | 'width' => 768, // as rotated |
50 | 80 | 'height' => 1024, // as rotated |
| 81 | + 'thumbWidth' => 450, |
| 82 | + 'thumbHeight' => 600, |
51 | 83 | ) |
52 | 84 | ) |
53 | 85 | ); |