MediaWiki
REL1_22
|
00001 <?php 00005 class JpegTest extends MediaWikiTestCase { 00006 00007 protected function setUp() { 00008 parent::setUp(); 00009 if ( !extension_loaded( 'exif' ) ) { 00010 $this->markTestSkipped( "This test needs the exif extension." ); 00011 } 00012 00013 $this->filePath = __DIR__ . '/../../data/media/'; 00014 00015 00016 $this->setMwGlobals( 'wgShowEXIF', true ); 00017 } 00018 00019 public function testInvalidFile() { 00020 $jpeg = new JpegHandler; 00021 $res = $jpeg->getMetadata( null, $this->filePath . 'README' ); 00022 $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); 00023 } 00024 00025 public function testJpegMetadataExtraction() { 00026 $h = new JpegHandler; 00027 $res = $h->getMetadata( null, $this->filePath . 'test.jpg' ); 00028 $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;}'; 00029 00030 // Unserialize in case serialization format ever changes. 00031 $this->assertEquals( unserialize( $expected ), unserialize( $res ) ); 00032 } 00033 }