<?php
class BitmapMetadataHandlerTest extends MediaWikiTestCase {
- public function setUp() {
+ protected function setUp() {
+ parent::setUp();
+
+ $this->setMwGlobals( 'wgShowEXIF', false );
+
$this->filePath = __DIR__ . '/../../data/media/';
}
* translation (to en) where XMP should win.
*/
public function testMultilingualCascade() {
+ global $wgShowEXIF;
+
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
}
if ( !wfDl( 'xml' ) ) {
$this->markTestSkipped( "This test needs the xml extension." );
}
- global $wgShowEXIF;
- $oldExif = $wgShowEXIF;
+
$wgShowEXIF = true;
$meta = BitmapMetadataHandler::Jpeg( $this->filePath .
$expected = array(
'x-default' => 'right(iptc)',
- 'en' => 'right translation',
- '_type' => 'lang'
+ 'en' => 'right translation',
+ '_type' => 'lang'
);
-
+
$this->assertArrayHasKey( 'ImageDescription', $meta,
'Did not extract any ImageDescription info?!' );
$this->assertEquals( $expected, $meta['ImageDescription'] );
-
- $wgShowEXIF = $oldExif;
}
/**
$this->assertEquals( '2020:07:14 01:36:05', $meta['DateTimeDigitized'] );
$this->assertEquals( '1997:03:02 00:01:02', $meta['DateTimeOriginal'] );
}
+
/**
* File has an invalid time (+ one valid but really weird time)
* that shouldn't be included
}
$handler = new BitmapMetadataHandler();
$result = $handler->png( $this->filePath . 'xmp.png' );
- $expected = array (
+ $expected = array(
'frameCount' => 0,
'loopCount' => 1,
'duration' => 0,
'bitDepth' => 1,
'colorType' => 'index-coloured',
- 'metadata' => array (
+ 'metadata' => array(
'SerialNumber' => '123456789',
'_MW_PNG_VERSION' => 1,
),
);
- $this->assertEquals( $expected, $result );
+ $this->assertEquals( $expected, $result );
}
+
public function testPNGNative() {
$handler = new BitmapMetadataHandler();
$result = $handler->png( $this->filePath . 'Png-native-test.png' );
$expected = 'http://example.com/url';
- $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] );
+ $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] );
}
+
public function testTiffByteOrder() {
$handler = new BitmapMetadataHandler();
$res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' );