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