wiki.techinc.nl/tests/phpunit/includes/media/ExifTest.php
Gilles Dubuc 84e4d75088 Use file width/height instead of metadata for getContentHeaders
This allows us to populate X-Content-Dimensions without touching the
existing metadata format. Which makes the migration of existing content a lot faster by
only having to run refreshFileHeaders.

Bug: T150741
Change-Id: I2c0f39b2b01f364c3fab997ccc2f874b7f101d8a
2017-05-23 19:18:58 +00:00

47 lines
1.1 KiB
PHP

<?php
/**
* @group Media
* @covers Exif
*/
class ExifTest extends MediaWikiTestCase {
/** @var string */
protected $mediaPath;
protected function setUp() {
parent::setUp();
$this->checkPHPExtension( 'exif' );
$this->mediaPath = __DIR__ . '/../../data/media/';
$this->setMwGlobals( 'wgShowEXIF', true );
}
public function testGPSExtraction() {
$filename = $this->mediaPath . 'exif-gps.jpg';
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
$exif = new Exif( $filename, $seg['byteOrder'] );
$data = $exif->getFilteredData();
$expected = [
'GPSLatitude' => 88.5180555556,
'GPSLongitude' => -21.12357,
'GPSAltitude' => -3.141592653,
'GPSDOP' => '5/1',
'GPSVersionID' => '2.2.0.0',
];
$this->assertEquals( $expected, $data, '', 0.0000000001 );
}
public function testUnicodeUserComment() {
$filename = $this->mediaPath . 'exif-user-comment.jpg';
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
$exif = new Exif( $filename, $seg['byteOrder'] );
$data = $exif->getFilteredData();
$expected = [
'UserComment' => 'test⁔comment',
];
$this->assertEquals( $expected, $data );
}
}