MediaWiki
REL1_19
|
00001 <?php 00002 class ExifTest extends MediaWikiTestCase { 00003 00004 public function setUp() { 00005 $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/'; 00006 00007 if ( !wfDl( 'exif' ) ) { 00008 $this->markTestSkipped( "This test needs the exif extension." ); 00009 } 00010 global $wgShowEXIF; 00011 $this->showExif = $wgShowEXIF; 00012 $wgShowEXIF = true; 00013 } 00014 public function tearDown() { 00015 global $wgShowEXIF; 00016 $wgShowEXIF = $this->showExif; 00017 } 00018 00019 public function testGPSExtraction() { 00020 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' => -200, 00029 'GPSDOP' => '5/1', 00030 'GPSVersionID' => '2.2.0.0', 00031 ); 00032 $this->assertEquals( $expected, $data, '', 0.0000000001 ); 00033 } 00034 public function testUnicodeUserComment() { 00035 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 00047 00048 }