http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97398

Revision: 97398
Author:   bawolff
Date:     2011-09-18 01:53:09 +0000 (Sun, 18 Sep 2011)
Log Message:
-----------
Follow-up r92635 Make sure the Exif related tests handle not having the Exif 
extension available properly

This should fix issues reported in 
http://lists.wikimedia.org/pipermail/wikitech-l/2011-September/055212.html Lots 
of these tests loaded the exif extension dynamically, but then didn't reset 
$wgShowEXIF var properly.

Also change some of the markTestIncomplete to markTestSkipped as that seemed 
more correct.

Modified Paths:
--------------
    trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
    trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php
    trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php
    trunk/phase3/tests/phpunit/includes/media/ExifTest.php
    trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php
    trunk/phase3/tests/phpunit/includes/media/JpegTest.php
    trunk/phase3/tests/phpunit/includes/media/XMPTest.php

Modified: 
trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php     
2011-09-17 22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php     
2011-09-18 01:53:09 UTC (rev 97398)
@@ -15,8 +15,14 @@
         */
        public function testMultilingualCascade() {
                if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
+                       $this->markTestSkipped( "This test needs the exif 
extension." );
                }
+               if ( !wfDl( 'xml' ) ) {
+                       $this->markTestSkipped( "This test needs the xml 
extension." );
+               }
+               global $wgShowEXIF;
+               $oldExif = $wgShowEXIF;
+               $wgShowEXIF = true;
 
                $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
                        '/Xmp-exif-multilingual_test.jpg' );
@@ -31,6 +37,8 @@
                        'Did not extract any ImageDescription info?!' );
 
                $this->assertEquals( $expected, $meta['ImageDescription'] );
+
+               $wgShowEXIF = $oldExif;
        }
 
        /**
@@ -94,6 +102,9 @@
        }
 
        public function testPNGXMP() {
+               if ( !wfDl( 'xml' ) ) {
+                       $this->markTestSkipped( "This test needs the xml 
extension." );
+               }
                $handler = new BitmapMetadataHandler();
                $result = $handler->png( $this->filePath . 'xmp.png' );
                $expected = array (

Modified: trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php        
2011-09-17 22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php        
2011-09-18 01:53:09 UTC (rev 97398)
@@ -7,46 +7,29 @@
                $this->showExif = $wgShowEXIF;
                $wgShowEXIF = true;
                $this->handler = new ExifBitmapHandler;
+               if ( !wfDl( 'exif' ) ) {
+                       $this->markTestSkipped( "This test needs the exif 
extension." );
+               }
        }
 
-       public function tearDown() {
-               global $wgShowEXIF;
-               $wgShowEXIF = $this->showExif;
-       }
-
        public function testIsOldBroken() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $res = $this->handler->isMetadataValid( null, 
ExifBitmapHandler::OLD_BROKEN_FILE );
                $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, 
$res );
        }
        public function testIsBrokenFile() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $res = $this->handler->isMetadataValid( null, 
ExifBitmapHandler::BROKEN_FILE );
                $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
        }
        public function testIsInvalid() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $res = $this->handler->isMetadataValid( null, 'Something 
Invalid Here.' );
                $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );
        }
        public function testGoodMetadata() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $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;}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
        }
        public function testIsOldGood() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $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;}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, 
$res );
@@ -54,9 +37,6 @@
        // Handle metadata from paged tiff handler (gotten via instant commons)
        // gracefully.
        public function testPagedTiffHandledGracefully() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $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";}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );

Modified: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php      
2011-09-17 22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php      
2011-09-18 01:53:09 UTC (rev 97398)
@@ -9,7 +9,17 @@
                parent::setUp();
                $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
                $this->handler = new BitmapHandler();
+               if ( !wfDl( 'exif' ) ) {
+                       $this->markTestSkipped( "This test needs the exif 
extension." );
+               }
+               global $wgShowEXIF;
+               $this->show = $wgShowEXIF;
+               $wgShowEXIF = true;
        }
+       public function tearDown() {
+               global $wgShowEXIF;
+               $wgShowEXIF = $this->show;
+       }
 
        /**
         *
@@ -33,7 +43,7 @@
                
                # Any further test require a scaler that can rotate
                if ( !BitmapHandler::canRotate() ) {
-                       $this->markTestIncomplete( 'Scaler does not support 
rotation' );
+                       $this->markTestSkipped( 'Scaler does not support 
rotation' );
                        return;
                }
                
@@ -102,6 +112,11 @@
        }
 
        function testWidthFlipping() {
+               # Any further test require a scaler that can rotate
+               if ( !BitmapHandler::canRotate() ) {
+                       $this->markTestSkipped( 'Scaler does not support 
rotation' );
+                       return;
+               }
                $file = UnregisteredLocalFile::newFromPath( $this->filePath . 
'portrait-rotated.jpg', 'image/jpeg' );
                $params = array( 'width' => '50' );
                $this->assertTrue( $this->handler->normaliseParams( $file, 
$params ) );

Modified: trunk/phase3/tests/phpunit/includes/media/ExifTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/ExifTest.php      2011-09-17 
22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/ExifTest.php      2011-09-18 
01:53:09 UTC (rev 97398)
@@ -4,6 +4,9 @@
        public function setUp() {
                $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/';
 
+               if ( !wfDl( 'exif' ) ) {
+                       $this->markTestSkipped( "This test needs the exif 
extension." );
+               }
                 global $wgShowEXIF;
                 $this->showExif = $wgShowEXIF;
                 $wgShowEXIF = true;
@@ -14,9 +17,6 @@
         }
 
        public function testGPSExtraction() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
 
                $filename = $this->mediaPath . 'exif-gps.jpg';
                $seg = JpegMetadataExtractor::segmentSplitter( $filename ); 
@@ -32,9 +32,6 @@
                $this->assertEquals( $expected, $data, '', 0.0000000001 );
        }
        public function testUnicodeUserComment() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
 
                $filename = $this->mediaPath . 'exif-user-comment.jpg';
                $seg = JpegMetadataExtractor::segmentSplitter( $filename ); 

Modified: trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php    
2011-09-17 22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php    
2011-09-18 01:53:09 UTC (rev 97398)
@@ -1,10 +1,19 @@
 <?php
 class FormatMetadataTest extends MediaWikiTestCase {
-       public function testInvalidDate() {
+       public function setUp() {
                if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
+                       $this->markTestSkipped( "This test needs the exif 
extension." );
                }
-               
+               global $wgShowEXIF;
+               $this->show = $wgShowEXIF;
+               $wgShowEXIF = true;
+       }
+       public function tearDown() {
+               global $wgShowEXIF;
+               $wgShowEXIF = $this->show;
+       }
+
+       public function testInvalidDate() {
                $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) 
. 
                        '/../../data/media/broken_exif_date.jpg', 'image/jpeg' 
);
                

Modified: trunk/phase3/tests/phpunit/includes/media/JpegTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/JpegTest.php      2011-09-17 
22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/JpegTest.php      2011-09-18 
01:53:09 UTC (rev 97398)
@@ -3,20 +3,24 @@
 
        public function setUp() {
                $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
+               if ( !wfDl( 'exif' ) ) {
+                       $this->markTestSkipped( "This test needs the exif 
extension." );
+               }
+               global $wgShowEXIF;
+               $this->show = $wgShowEXIF;
+               $wgShowEXIF = true;
        }
+       public function tearDown() {
+               global $wgShowEXIF;
+               $wgShowEXIF = $this->show;
+       }
 
        public function testInvalidFile() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $jpeg = new JpegHandler;
                $res = $jpeg->getMetadata( null, $this->filePath . 'README' );
                $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
        }
        public function testJpegMetadataExtraction() {
-               if ( !wfDl( 'exif' ) ) {
-                       $this->markTestIncomplete( "This test needs the exif 
extension." );
-               }
                $h = new JpegHandler;
                $res = $h->getMetadata( null, $this->filePath . 'test.jpg' );
                $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;}';

Modified: trunk/phase3/tests/phpunit/includes/media/XMPTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/XMPTest.php       2011-09-17 
22:29:16 UTC (rev 97397)
+++ trunk/phase3/tests/phpunit/includes/media/XMPTest.php       2011-09-18 
01:53:09 UTC (rev 97398)
@@ -1,6 +1,12 @@
 <?php
 class XMPTest extends MediaWikiTestCase {
 
+       function setUp() {
+               if ( !wfDl( 'xml' ) ) {
+                       $this->markTestSkipped( 'Requires libxml to do XMP 
parsing' );
+               }
+       }
+
        /**
         * Put XMP in, compare what comes out...
         *
@@ -11,9 +17,6 @@
         * @dataProvider dataXMPParse
         */
        public function testXMPParse( $xmp, $expected, $info ) {
-               if ( !function_exists( 'xml_parser_create_ns' ) ) {
-                       $this->markIncomplete( 'Requires libxml to do XMP 
parsing' );
-               }
                if ( !is_string( $xmp ) || !is_array( $expected ) ) {
                        throw new Exception( "Invalid data provided to " . 
__METHOD__ );
                }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to