r94825 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94824‎ | r94825 | r94826 >
Date:21:53, 17 August 2011
Author:bawolff
Status:ok
Tags:
Comment:
follow-up r91885 - address CR comments

* rename testTiffFile to something more descriptive
* unserialize the serialized results before comparing
Also follow-up r92635 - rm an extra wfDl that was outside any functions, and I'm assuming accidentally there (?)
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/media/JpegTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/TiffTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/media/JpegTest.php
@@ -1,6 +1,4 @@
22 <?php
3 -wfDl('exif');
4 -
53 class JpegTest extends MediaWikiTestCase {
64
75 public function testInvalidFile() {
@@ -18,7 +16,8 @@
1917 $h = new JpegHandler;
2018 $res = $h->getMetadata( null, dirname( __FILE__ ) . '/test.jpg' );
2119 $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;}';
22 - // Hopefully php always serializes things in the same order.
23 - $this->assertEquals( $expected, $res );
 20+
 21+ // Unserialize in case serialization format ever changes.
 22+ $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
2423 }
2524 }
Index: trunk/phase3/tests/phpunit/includes/media/TiffTest.php
@@ -21,14 +21,15 @@
2222 $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
2323 }
2424
25 - public function testTiffFile() {
 25+ public function testTiffMetadataExtraction() {
2626 if ( !wfDl( 'exif' ) ) {
2727 $this->markTestIncomplete( "This test needs the exif extension." );
2828 }
2929 $tiff = new TiffHandler;
3030 $res = $tiff->getMetadata( null, dirname( __FILE__ ) . '/test.tiff' );
3131 $expected = '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;}';
32 - // Hopefully php always serializes things in the same order.
33 - $this->assertEquals( $expected, $res );
 32+ // Re-unserialize in case there are subtle differences between how versions
 33+ // of php serialize stuff.
 34+ $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
3435 }
3536 }

Sign-offs

UserFlagDate
Ucuchainspected01:14, 18 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r94862follow-up r91885 rename testTiffFile since its not about tiff files...bawolff03:53, 18 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91885(follow-up r90256) Unit tests.bawolff16:42, 11 July 2011
r92635I like better checking for the actual extension, loading if needed (and able).platonides15:24, 20 July 2011

Status & tagging log