2011-06-19 21:38:58 +00:00
|
|
|
<?php
|
|
|
|
|
class FormatMetadataTest extends MediaWikiTestCase {
|
|
|
|
|
public function testInvalidDate() {
|
2011-06-29 20:24:53 +00:00
|
|
|
global $wgShowEXIF;
|
|
|
|
|
if ( !$wgShowEXIF ) {
|
|
|
|
|
$this->markTestIncomplete( "This test needs the exif extension." );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 21:38:58 +00:00
|
|
|
$file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) .
|
|
|
|
|
'/broken_exif_date.jpg', 'image/jpeg' );
|
|
|
|
|
|
|
|
|
|
// Throws an error if bug hit
|
|
|
|
|
$meta = $file->formatMetadata();
|
2011-06-29 20:24:53 +00:00
|
|
|
$this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
|
2011-06-19 21:38:58 +00:00
|
|
|
|
|
|
|
|
// Find date exif entry
|
|
|
|
|
$this->assertArrayHasKey( 'visible', $meta );
|
|
|
|
|
$dateIndex = null;
|
|
|
|
|
foreach ( $meta['visible'] as $i => $data ) {
|
|
|
|
|
if ( $data['id'] == 'exif-datetimeoriginal' ) {
|
|
|
|
|
$dateIndex = $i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
|
|
|
|
|
$this->assertEquals( '0000:01:00 00:02:27',
|
|
|
|
|
$meta['visible'][$dateIndex]['value'],
|
|
|
|
|
'File with invalid date metadata (bug 29471)' );
|
|
|
|
|
}
|
|
|
|
|
}
|