Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / media / ExifTest.php
blobb2f26eebaba639a28521a705de2ce48c55a3533c
1 <?php
3 /**
4 * @group Media
5 * @covers Exif
6 */
7 class ExifTest extends MediaWikiTestCase {
9 /** @var string */
10 protected $mediaPath;
12 protected function setUp() {
13 parent::setUp();
14 $this->checkPHPExtension( 'exif' );
16 $this->mediaPath = __DIR__ . '/../../data/media/';
18 $this->setMwGlobals( 'wgShowEXIF', true );
21 public function testGPSExtraction() {
22 $filename = $this->mediaPath . 'exif-gps.jpg';
23 $seg = JpegMetadataExtractor::segmentSplitter( $filename );
24 $exif = new Exif( $filename, $seg['byteOrder'] );
25 $data = $exif->getFilteredData();
26 $expected = [
27 'GPSLatitude' => 88.5180555556,
28 'GPSLongitude' => -21.12357,
29 'GPSAltitude' => -3.141592653,
30 'GPSDOP' => '5/1',
31 'GPSVersionID' => '2.2.0.0',
33 $this->assertEquals( $expected, $data, '', 0.0000000001 );
36 public function testUnicodeUserComment() {
37 $filename = $this->mediaPath . 'exif-user-comment.jpg';
38 $seg = JpegMetadataExtractor::segmentSplitter( $filename );
39 $exif = new Exif( $filename, $seg['byteOrder'] );
40 $data = $exif->getFilteredData();
42 $expected = [
43 'UserComment' => 'test⁔comment'
45 $this->assertEquals( $expected, $data );