MediaWiki
REL1_20
|
00001 <?php 00002 class ExifTest extends MediaWikiTestCase { 00003 00004 public function setUp() { 00005 $this->mediaPath = __DIR__ . '/../../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 00015 public function tearDown() { 00016 global $wgShowEXIF; 00017 $wgShowEXIF = $this->showExif; 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 00047 00048 }