Index: trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php |
— | — | @@ -1,10 +1,19 @@ |
2 | 2 | <?php |
3 | 3 | class FormatMetadataTest extends MediaWikiTestCase { |
4 | | - public function testInvalidDate() { |
| 4 | + public function setUp() { |
5 | 5 | if ( !wfDl( 'exif' ) ) { |
6 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
| 6 | + $this->markTestSkipped( "This test needs the exif extension." ); |
7 | 7 | } |
8 | | - |
| 8 | + global $wgShowEXIF; |
| 9 | + $this->show = $wgShowEXIF; |
| 10 | + $wgShowEXIF = true; |
| 11 | + } |
| 12 | + public function tearDown() { |
| 13 | + global $wgShowEXIF; |
| 14 | + $wgShowEXIF = $this->show; |
| 15 | + } |
| 16 | + |
| 17 | + public function testInvalidDate() { |
9 | 18 | $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) . |
10 | 19 | '/../../data/media/broken_exif_date.jpg', 'image/jpeg' ); |
11 | 20 | |
Index: trunk/phase3/tests/phpunit/includes/media/ExifTest.php |
— | — | @@ -4,6 +4,9 @@ |
5 | 5 | public function setUp() { |
6 | 6 | $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/'; |
7 | 7 | |
| 8 | + if ( !wfDl( 'exif' ) ) { |
| 9 | + $this->markTestSkipped( "This test needs the exif extension." ); |
| 10 | + } |
8 | 11 | global $wgShowEXIF; |
9 | 12 | $this->showExif = $wgShowEXIF; |
10 | 13 | $wgShowEXIF = true; |
— | — | @@ -14,9 +17,6 @@ |
15 | 18 | } |
16 | 19 | |
17 | 20 | public function testGPSExtraction() { |
18 | | - if ( !wfDl( 'exif' ) ) { |
19 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
20 | | - } |
21 | 21 | |
22 | 22 | $filename = $this->mediaPath . 'exif-gps.jpg'; |
23 | 23 | $seg = JpegMetadataExtractor::segmentSplitter( $filename ); |
— | — | @@ -32,9 +32,6 @@ |
33 | 33 | $this->assertEquals( $expected, $data, '', 0.0000000001 ); |
34 | 34 | } |
35 | 35 | public function testUnicodeUserComment() { |
36 | | - if ( !wfDl( 'exif' ) ) { |
37 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
38 | | - } |
39 | 36 | |
40 | 37 | $filename = $this->mediaPath . 'exif-user-comment.jpg'; |
41 | 38 | $seg = JpegMetadataExtractor::segmentSplitter( $filename ); |
Index: trunk/phase3/tests/phpunit/includes/media/XMPTest.php |
— | — | @@ -1,6 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | class XMPTest extends MediaWikiTestCase { |
4 | 4 | |
| 5 | + function setUp() { |
| 6 | + if ( !wfDl( 'xml' ) ) { |
| 7 | + $this->markTestSkipped( 'Requires libxml to do XMP parsing' ); |
| 8 | + } |
| 9 | + } |
| 10 | + |
5 | 11 | /** |
6 | 12 | * Put XMP in, compare what comes out... |
7 | 13 | * |
— | — | @@ -11,9 +17,6 @@ |
12 | 18 | * @dataProvider dataXMPParse |
13 | 19 | */ |
14 | 20 | public function testXMPParse( $xmp, $expected, $info ) { |
15 | | - if ( !function_exists( 'xml_parser_create_ns' ) ) { |
16 | | - $this->markIncomplete( 'Requires libxml to do XMP parsing' ); |
17 | | - } |
18 | 21 | if ( !is_string( $xmp ) || !is_array( $expected ) ) { |
19 | 22 | throw new Exception( "Invalid data provided to " . __METHOD__ ); |
20 | 23 | } |
Index: trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php |
— | — | @@ -15,8 +15,14 @@ |
16 | 16 | */ |
17 | 17 | public function testMultilingualCascade() { |
18 | 18 | if ( !wfDl( 'exif' ) ) { |
19 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
| 19 | + $this->markTestSkipped( "This test needs the exif extension." ); |
20 | 20 | } |
| 21 | + if ( !wfDl( 'xml' ) ) { |
| 22 | + $this->markTestSkipped( "This test needs the xml extension." ); |
| 23 | + } |
| 24 | + global $wgShowEXIF; |
| 25 | + $oldExif = $wgShowEXIF; |
| 26 | + $wgShowEXIF = true; |
21 | 27 | |
22 | 28 | $meta = BitmapMetadataHandler::Jpeg( $this->filePath . |
23 | 29 | '/Xmp-exif-multilingual_test.jpg' ); |
— | — | @@ -31,6 +37,8 @@ |
32 | 38 | 'Did not extract any ImageDescription info?!' ); |
33 | 39 | |
34 | 40 | $this->assertEquals( $expected, $meta['ImageDescription'] ); |
| 41 | + |
| 42 | + $wgShowEXIF = $oldExif; |
35 | 43 | } |
36 | 44 | |
37 | 45 | /** |
— | — | @@ -94,6 +102,9 @@ |
95 | 103 | } |
96 | 104 | |
97 | 105 | public function testPNGXMP() { |
| 106 | + if ( !wfDl( 'xml' ) ) { |
| 107 | + $this->markTestSkipped( "This test needs the xml extension." ); |
| 108 | + } |
98 | 109 | $handler = new BitmapMetadataHandler(); |
99 | 110 | $result = $handler->png( $this->filePath . 'xmp.png' ); |
100 | 111 | $expected = array ( |
Index: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php |
— | — | @@ -9,7 +9,17 @@ |
10 | 10 | parent::setUp(); |
11 | 11 | $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; |
12 | 12 | $this->handler = new BitmapHandler(); |
| 13 | + if ( !wfDl( 'exif' ) ) { |
| 14 | + $this->markTestSkipped( "This test needs the exif extension." ); |
| 15 | + } |
| 16 | + global $wgShowEXIF; |
| 17 | + $this->show = $wgShowEXIF; |
| 18 | + $wgShowEXIF = true; |
13 | 19 | } |
| 20 | + public function tearDown() { |
| 21 | + global $wgShowEXIF; |
| 22 | + $wgShowEXIF = $this->show; |
| 23 | + } |
14 | 24 | |
15 | 25 | /** |
16 | 26 | * |
— | — | @@ -33,7 +43,7 @@ |
34 | 44 | |
35 | 45 | # Any further test require a scaler that can rotate |
36 | 46 | if ( !BitmapHandler::canRotate() ) { |
37 | | - $this->markTestIncomplete( 'Scaler does not support rotation' ); |
| 47 | + $this->markTestSkipped( 'Scaler does not support rotation' ); |
38 | 48 | return; |
39 | 49 | } |
40 | 50 | |
— | — | @@ -102,6 +112,11 @@ |
103 | 113 | } |
104 | 114 | |
105 | 115 | function testWidthFlipping() { |
| 116 | + # Any further test require a scaler that can rotate |
| 117 | + if ( !BitmapHandler::canRotate() ) { |
| 118 | + $this->markTestSkipped( 'Scaler does not support rotation' ); |
| 119 | + return; |
| 120 | + } |
106 | 121 | $file = UnregisteredLocalFile::newFromPath( $this->filePath . 'portrait-rotated.jpg', 'image/jpeg' ); |
107 | 122 | $params = array( 'width' => '50' ); |
108 | 123 | $this->assertTrue( $this->handler->normaliseParams( $file, $params ) ); |
Index: trunk/phase3/tests/phpunit/includes/media/JpegTest.php |
— | — | @@ -3,20 +3,24 @@ |
4 | 4 | |
5 | 5 | public function setUp() { |
6 | 6 | $this->filePath = dirname( __FILE__ ) . '/../../data/media/'; |
| 7 | + if ( !wfDl( 'exif' ) ) { |
| 8 | + $this->markTestSkipped( "This test needs the exif extension." ); |
| 9 | + } |
| 10 | + global $wgShowEXIF; |
| 11 | + $this->show = $wgShowEXIF; |
| 12 | + $wgShowEXIF = true; |
7 | 13 | } |
| 14 | + public function tearDown() { |
| 15 | + global $wgShowEXIF; |
| 16 | + $wgShowEXIF = $this->show; |
| 17 | + } |
8 | 18 | |
9 | 19 | public function testInvalidFile() { |
10 | | - if ( !wfDl( 'exif' ) ) { |
11 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
12 | | - } |
13 | 20 | $jpeg = new JpegHandler; |
14 | 21 | $res = $jpeg->getMetadata( null, $this->filePath . 'README' ); |
15 | 22 | $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); |
16 | 23 | } |
17 | 24 | public function testJpegMetadataExtraction() { |
18 | | - if ( !wfDl( 'exif' ) ) { |
19 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
20 | | - } |
21 | 25 | $h = new JpegHandler; |
22 | 26 | $res = $h->getMetadata( null, $this->filePath . 'test.jpg' ); |
23 | 27 | $expected = 'a:7:{s:16:"ImageDescription";s:9:"Test file";s:11:"XResolution";s:4:"72/1";s:11:"YResolution";s:4:"72/1";s:14:"ResolutionUnit";i:2;s:16:"YCbCrPositioning";i:1;s:15:"JPEGFileComment";a:1:{i:0;s:17:"Created with GIMP";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; |
Index: trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php |
— | — | @@ -7,46 +7,29 @@ |
8 | 8 | $this->showExif = $wgShowEXIF; |
9 | 9 | $wgShowEXIF = true; |
10 | 10 | $this->handler = new ExifBitmapHandler; |
| 11 | + if ( !wfDl( 'exif' ) ) { |
| 12 | + $this->markTestSkipped( "This test needs the exif extension." ); |
| 13 | + } |
11 | 14 | } |
12 | 15 | |
13 | | - public function tearDown() { |
14 | | - global $wgShowEXIF; |
15 | | - $wgShowEXIF = $this->showExif; |
16 | | - } |
17 | | - |
18 | 16 | public function testIsOldBroken() { |
19 | | - if ( !wfDl( 'exif' ) ) { |
20 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
21 | | - } |
22 | 17 | $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE ); |
23 | 18 | $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res ); |
24 | 19 | } |
25 | 20 | public function testIsBrokenFile() { |
26 | | - if ( !wfDl( 'exif' ) ) { |
27 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
28 | | - } |
29 | 21 | $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE ); |
30 | 22 | $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res ); |
31 | 23 | } |
32 | 24 | public function testIsInvalid() { |
33 | | - if ( !wfDl( 'exif' ) ) { |
34 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
35 | | - } |
36 | 25 | $res = $this->handler->isMetadataValid( null, 'Something Invalid Here.' ); |
37 | 26 | $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res ); |
38 | 27 | } |
39 | 28 | public function testGoodMetadata() { |
40 | | - if ( !wfDl( 'exif' ) ) { |
41 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
42 | | - } |
43 | 29 | $meta = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}'; |
44 | 30 | $res = $this->handler->isMetadataValid( null, $meta ); |
45 | 31 | $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res ); |
46 | 32 | } |
47 | 33 | public function testIsOldGood() { |
48 | | - if ( !wfDl( 'exif' ) ) { |
49 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
50 | | - } |
51 | 34 | $meta = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:1;}'; |
52 | 35 | $res = $this->handler->isMetadataValid( null, $meta ); |
53 | 36 | $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res ); |
— | — | @@ -54,9 +37,6 @@ |
55 | 38 | // Handle metadata from paged tiff handler (gotten via instant commons) |
56 | 39 | // gracefully. |
57 | 40 | public function testPagedTiffHandledGracefully() { |
58 | | - if ( !wfDl( 'exif' ) ) { |
59 | | - $this->markTestIncomplete( "This test needs the exif extension." ); |
60 | | - } |
61 | 41 | $meta = 'a:6:{s:9:"page_data";a:1:{i:1;a:5:{s:5:"width";i:643;s:6:"height";i:448;s:5:"alpha";s:4:"true";s:4:"page";i:1;s:6:"pixels";i:288064;}}s:10:"page_count";i:1;s:10:"first_page";i:1;s:9:"last_page";i:1;s:4:"exif";a:9:{s:10:"ImageWidth";i:643;s:11:"ImageLength";i:448;s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:4;s:12:"RowsPerStrip";i:50;s:19:"PlanarConfiguration";i:1;s:22:"MEDIAWIKI_EXIF_VERSION";i:1;}s:21:"TIFF_METADATA_VERSION";s:3:"1.4";}'; |
62 | 42 | $res = $this->handler->isMetadataValid( null, $meta ); |
63 | 43 | $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res ); |