MediaWiki
REL1_22
|
00001 <?php 00002 class ExifTest extends MediaWikiTestCase { 00003 00005 protected $mediaPath; 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->mediaPath = __DIR__ . '/../../data/media/'; 00014 00015 00016 00017 $this->setMwGlobals( 'wgShowEXIF', true ); 00018 } 00019 00020 public function testGPSExtraction() { 00021 $filename = $this->mediaPath . 'exif-gps.jpg'; 00022 $seg = JpegMetadataExtractor::segmentSplitter( $filename ); 00023 $exif = new Exif( $filename, $seg['byteOrder'] ); 00024 $data = $exif->getFilteredData(); 00025 $expected = array( 00026 'GPSLatitude' => 88.5180555556, 00027 'GPSLongitude' => -21.12357, 00028 'GPSAltitude' => -3.141592653, 00029 'GPSDOP' => '5/1', 00030 'GPSVersionID' => '2.2.0.0', 00031 ); 00032 $this->assertEquals( $expected, $data, '', 0.0000000001 ); 00033 } 00034 00035 public function testUnicodeUserComment() { 00036 $filename = $this->mediaPath . 'exif-user-comment.jpg'; 00037 $seg = JpegMetadataExtractor::segmentSplitter( $filename ); 00038 $exif = new Exif( $filename, $seg['byteOrder'] ); 00039 $data = $exif->getFilteredData(); 00040 00041 $expected = array( 00042 'UserComment' => 'testâcomment' 00043 ); 00044 $this->assertEquals( $expected, $data ); 00045 } 00046 }