(follow-up r86169) Moar unit-tests!! (sorry for uttetly huge commit)
[lhc/web/wiklou.git] / tests / phpunit / includes / media / ExifTest.php
1 <?php
2 class ExifTest extends MediaWikiTestCase {
3
4 public function setUp() {
5 $this->mediaPath = dirname( __FILE__ ) . '/../../data/media/';
6
7 global $wgShowEXIF;
8 $this->showExif = $wgShowEXIF;
9 $wgShowEXIF = true;
10 }
11 public function tearDown() {
12 global $wgShowEXIF;
13 $wgShowEXIF = $this->showExif;
14 }
15
16 public function testGPSExtraction() {
17 if ( !wfDl( 'exif' ) ) {
18 $this->markTestIncomplete( "This test needs the exif extension." );
19 }
20
21 $filename = $this->mediaPath . 'exif-gps.jpg';
22 $seg = JpegMetadataExtractor::segmentSplitter( $filename );
23 $exif = new Exif( $filename, $seg['byteOrder'] );
24 $data = $exif->getFilteredData();
25 $expected = array(
26 'GPSLatitude' => 88.5180555556,
27 'GPSLongitude' => -21.12357,
28 'GPSAltitude' => -200,
29 'GPSDOP' => '5/1',
30 'GPSVersionID' => '2.2.0.0',
31 );
32 $this->assertEquals( $expected, $data, '', 0.0000000001 );
33 }
34 public function testUnicodeUserComment() {
35 if ( !wfDl( 'exif' ) ) {
36 $this->markTestIncomplete( "This test needs the exif extension." );
37 }
38
39 $filename = $this->mediaPath . 'exif-user-comment.jpg';
40 $seg = JpegMetadataExtractor::segmentSplitter( $filename );
41 $exif = new Exif( $filename, $seg['byteOrder'] );
42 $data = $exif->getFilteredData();
43
44 $expected = array(
45 'UserComment' => 'test⁔comment'
46 );
47 $this->assertEquals( $expected, $data );
48 }
49
50
51 }