2011-06-23 23:25:49 +00:00
|
|
|
<?php
|
|
|
|
|
class BitmapMetadataHandlerTest extends MediaWikiTestCase {
|
2011-08-17 23:28:31 +00:00
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
|
$this->filePath = dirname( __FILE__ ) . '/../../data/media/';
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 23:25:49 +00:00
|
|
|
/**
|
|
|
|
|
* Test if having conflicting metadata values from different
|
|
|
|
|
* types of metadata, that the right one takes precedence.
|
|
|
|
|
*
|
|
|
|
|
* Basically the file has IPTC and XMP metadata, the
|
|
|
|
|
* IPTC should override the XMP, except for the multilingual
|
|
|
|
|
* translation (to en) where XMP should win.
|
|
|
|
|
*/
|
|
|
|
|
public function testMultilingualCascade() {
|
2011-07-20 15:35:48 +00:00
|
|
|
if ( !wfDl( 'exif' ) ) {
|
2011-06-29 13:45:57 +00:00
|
|
|
$this->markTestIncomplete( "This test needs the exif extension." );
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 23:28:31 +00:00
|
|
|
$meta = BitmapMetadataHandler::Jpeg( $this->filePath .
|
2011-06-23 23:25:49 +00:00
|
|
|
'/Xmp-exif-multilingual_test.jpg' );
|
|
|
|
|
|
|
|
|
|
$expected = array(
|
|
|
|
|
'x-default' => 'right(iptc)',
|
|
|
|
|
'en' => 'right translation',
|
|
|
|
|
'_type' => 'lang'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'ImageDescription', $meta,
|
|
|
|
|
'Did not extract any ImageDescription info?!' );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $expected, $meta['ImageDescription'] );
|
|
|
|
|
}
|
2011-08-18 05:45:04 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test for jpeg comments are being handled by
|
|
|
|
|
* BitmapMetadataHandler correctly.
|
|
|
|
|
*
|
|
|
|
|
* There's more extensive tests of comment extraction in
|
|
|
|
|
* JpegMetadataExtractorTests.php
|
|
|
|
|
*/
|
|
|
|
|
public function testJpegComment() {
|
|
|
|
|
$meta = BitmapMetadataHandler::Jpeg( $this->filePath .
|
|
|
|
|
'jpeg-comment-utf.jpg' );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( 'UTF-8 JPEG Comment — ¼',
|
|
|
|
|
$meta['JPEGFileComment'][0] );
|
|
|
|
|
}
|
2011-06-23 23:25:49 +00:00
|
|
|
}
|