r97398 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97397‎ | r97398 | r97399 >
Date:01:53, 18 September 2011
Author:bawolff
Status:resolved (Comments)
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/ExifBitmapTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/ExifTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/JpegTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/XMPTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/media/FormatMetadataTest.php
@@ -1,10 +1,19 @@
22 <?php
33 class FormatMetadataTest extends MediaWikiTestCase {
4 - public function testInvalidDate() {
 4+ public function setUp() {
55 if ( !wfDl( 'exif' ) ) {
6 - $this->markTestIncomplete( "This test needs the exif extension." );
 6+ $this->markTestSkipped( "This test needs the exif extension." );
77 }
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() {
918 $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) .
1019 '/../../data/media/broken_exif_date.jpg', 'image/jpeg' );
1120
Index: trunk/phase3/tests/phpunit/includes/media/ExifTest.php
@@ -4,6 +4,9 @@
55 public function setUp() {
66 $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/';
77
 8+ if ( !wfDl( 'exif' ) ) {
 9+ $this->markTestSkipped( "This test needs the exif extension." );
 10+ }
811 global $wgShowEXIF;
912 $this->showExif = $wgShowEXIF;
1013 $wgShowEXIF = true;
@@ -14,9 +17,6 @@
1518 }
1619
1720 public function testGPSExtraction() {
18 - if ( !wfDl( 'exif' ) ) {
19 - $this->markTestIncomplete( "This test needs the exif extension." );
20 - }
2121
2222 $filename = $this->mediaPath . 'exif-gps.jpg';
2323 $seg = JpegMetadataExtractor::segmentSplitter( $filename );
@@ -32,9 +32,6 @@
3333 $this->assertEquals( $expected, $data, '', 0.0000000001 );
3434 }
3535 public function testUnicodeUserComment() {
36 - if ( !wfDl( 'exif' ) ) {
37 - $this->markTestIncomplete( "This test needs the exif extension." );
38 - }
3936
4037 $filename = $this->mediaPath . 'exif-user-comment.jpg';
4138 $seg = JpegMetadataExtractor::segmentSplitter( $filename );
Index: trunk/phase3/tests/phpunit/includes/media/XMPTest.php
@@ -1,6 +1,12 @@
22 <?php
33 class XMPTest extends MediaWikiTestCase {
44
 5+ function setUp() {
 6+ if ( !wfDl( 'xml' ) ) {
 7+ $this->markTestSkipped( 'Requires libxml to do XMP parsing' );
 8+ }
 9+ }
 10+
511 /**
612 * Put XMP in, compare what comes out...
713 *
@@ -11,9 +17,6 @@
1218 * @dataProvider dataXMPParse
1319 */
1420 public function testXMPParse( $xmp, $expected, $info ) {
15 - if ( !function_exists( 'xml_parser_create_ns' ) ) {
16 - $this->markIncomplete( 'Requires libxml to do XMP parsing' );
17 - }
1821 if ( !is_string( $xmp ) || !is_array( $expected ) ) {
1922 throw new Exception( "Invalid data provided to " . __METHOD__ );
2023 }
Index: trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
@@ -15,8 +15,14 @@
1616 */
1717 public function testMultilingualCascade() {
1818 if ( !wfDl( 'exif' ) ) {
19 - $this->markTestIncomplete( "This test needs the exif extension." );
 19+ $this->markTestSkipped( "This test needs the exif extension." );
2020 }
 21+ if ( !wfDl( 'xml' ) ) {
 22+ $this->markTestSkipped( "This test needs the xml extension." );
 23+ }
 24+ global $wgShowEXIF;
 25+ $oldExif = $wgShowEXIF;
 26+ $wgShowEXIF = true;
2127
2228 $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
2329 '/Xmp-exif-multilingual_test.jpg' );
@@ -31,6 +37,8 @@
3238 'Did not extract any ImageDescription info?!' );
3339
3440 $this->assertEquals( $expected, $meta['ImageDescription'] );
 41+
 42+ $wgShowEXIF = $oldExif;
3543 }
3644
3745 /**
@@ -94,6 +102,9 @@
95103 }
96104
97105 public function testPNGXMP() {
 106+ if ( !wfDl( 'xml' ) ) {
 107+ $this->markTestSkipped( "This test needs the xml extension." );
 108+ }
98109 $handler = new BitmapMetadataHandler();
99110 $result = $handler->png( $this->filePath . 'xmp.png' );
100111 $expected = array (
Index: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php
@@ -9,7 +9,17 @@
1010 parent::setUp();
1111 $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
1212 $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;
1319 }
 20+ public function tearDown() {
 21+ global $wgShowEXIF;
 22+ $wgShowEXIF = $this->show;
 23+ }
1424
1525 /**
1626 *
@@ -33,7 +43,7 @@
3444
3545 # Any further test require a scaler that can rotate
3646 if ( !BitmapHandler::canRotate() ) {
37 - $this->markTestIncomplete( 'Scaler does not support rotation' );
 47+ $this->markTestSkipped( 'Scaler does not support rotation' );
3848 return;
3949 }
4050
@@ -102,6 +112,11 @@
103113 }
104114
105115 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+ }
106121 $file = UnregisteredLocalFile::newFromPath( $this->filePath . 'portrait-rotated.jpg', 'image/jpeg' );
107122 $params = array( 'width' => '50' );
108123 $this->assertTrue( $this->handler->normaliseParams( $file, $params ) );
Index: trunk/phase3/tests/phpunit/includes/media/JpegTest.php
@@ -3,20 +3,24 @@
44
55 public function setUp() {
66 $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;
713 }
 14+ public function tearDown() {
 15+ global $wgShowEXIF;
 16+ $wgShowEXIF = $this->show;
 17+ }
818
919 public function testInvalidFile() {
10 - if ( !wfDl( 'exif' ) ) {
11 - $this->markTestIncomplete( "This test needs the exif extension." );
12 - }
1320 $jpeg = new JpegHandler;
1421 $res = $jpeg->getMetadata( null, $this->filePath . 'README' );
1522 $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
1623 }
1724 public function testJpegMetadataExtraction() {
18 - if ( !wfDl( 'exif' ) ) {
19 - $this->markTestIncomplete( "This test needs the exif extension." );
20 - }
2125 $h = new JpegHandler;
2226 $res = $h->getMetadata( null, $this->filePath . 'test.jpg' );
2327 $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 @@
88 $this->showExif = $wgShowEXIF;
99 $wgShowEXIF = true;
1010 $this->handler = new ExifBitmapHandler;
 11+ if ( !wfDl( 'exif' ) ) {
 12+ $this->markTestSkipped( "This test needs the exif extension." );
 13+ }
1114 }
1215
13 - public function tearDown() {
14 - global $wgShowEXIF;
15 - $wgShowEXIF = $this->showExif;
16 - }
17 -
1816 public function testIsOldBroken() {
19 - if ( !wfDl( 'exif' ) ) {
20 - $this->markTestIncomplete( "This test needs the exif extension." );
21 - }
2217 $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE );
2318 $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res );
2419 }
2520 public function testIsBrokenFile() {
26 - if ( !wfDl( 'exif' ) ) {
27 - $this->markTestIncomplete( "This test needs the exif extension." );
28 - }
2921 $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE );
3022 $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
3123 }
3224 public function testIsInvalid() {
33 - if ( !wfDl( 'exif' ) ) {
34 - $this->markTestIncomplete( "This test needs the exif extension." );
35 - }
3625 $res = $this->handler->isMetadataValid( null, 'Something Invalid Here.' );
3726 $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );
3827 }
3928 public function testGoodMetadata() {
40 - if ( !wfDl( 'exif' ) ) {
41 - $this->markTestIncomplete( "This test needs the exif extension." );
42 - }
4329 $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;}';
4430 $res = $this->handler->isMetadataValid( null, $meta );
4531 $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
4632 }
4733 public function testIsOldGood() {
48 - if ( !wfDl( 'exif' ) ) {
49 - $this->markTestIncomplete( "This test needs the exif extension." );
50 - }
5134 $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;}';
5235 $res = $this->handler->isMetadataValid( null, $meta );
5336 $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res );
@@ -54,9 +37,6 @@
5538 // Handle metadata from paged tiff handler (gotten via instant commons)
5639 // gracefully.
5740 public function testPagedTiffHandledGracefully() {
58 - if ( !wfDl( 'exif' ) ) {
59 - $this->markTestIncomplete( "This test needs the exif extension." );
60 - }
6141 $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";}';
6242 $res = $this->handler->isMetadataValid( null, $meta );
6343 $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97438Restore ExifBitmapTest::tearDown removed in r97398platonides20:36, 18 September 2011
r97656Further tweaks to r96687, r90016, r97398 etc tests: actually produce a thumbn...brion19:39, 20 September 2011
r97659Further tweaks to r96687, r90016, r97398, r97656 etc tests: try several thumb...brion20:04, 20 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92635I like better checking for the actual extension, loading if needed (and able).platonides15:24, 20 July 2011

Comments

#Comment by Platonides (talk | contribs)   20:35, 18 September 2011

You are removing ExifBitmapTest::tearDown()

Status & tagging log