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