MediaWiki
REL1_24
|
00001 <?php 00002 00007 class JpegTest extends MediaWikiMediaTestCase { 00008 00009 protected function setUp() { 00010 parent::setUp(); 00011 $this->checkPHPExtension( 'exif' ); 00012 00013 $this->setMwGlobals( 'wgShowEXIF', true ); 00014 00015 $this->handler = new JpegHandler; 00016 } 00017 00018 public function testInvalidFile() { 00019 $file = $this->dataFile( 'README', 'image/jpeg' ); 00020 $res = $this->handler->getMetadata( $file, $this->filePath . 'README' ); 00021 $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res ); 00022 } 00023 00024 public function testJpegMetadataExtraction() { 00025 $file = $this->dataFile( 'test.jpg', 'image/jpeg' ); 00026 $res = $this->handler->getMetadata( $file, $this->filePath . 'test.jpg' ); 00027 // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong 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 // @codingStandardsIgnoreEnd 00030 00031 // Unserialize in case serialization format ever changes. 00032 $this->assertEquals( unserialize( $expected ), unserialize( $res ) ); 00033 } 00034 00038 public function testGetIndependentMetaArray() { 00039 $file = $this->dataFile( 'test.jpg', 'image/jpeg' ); 00040 $res = $this->handler->getCommonMetaArray( $file ); 00041 $expected = array( 00042 'ImageDescription' => 'Test file', 00043 'XResolution' => '72/1', 00044 'YResolution' => '72/1', 00045 'ResolutionUnit' => 2, 00046 'YCbCrPositioning' => 1, 00047 'JPEGFileComment' => array( 00048 'Created with GIMP', 00049 ), 00050 ); 00051 00052 $this->assertEquals( $res, $expected ); 00053 } 00054 }