diff options
Diffstat (limited to 'tests/phpunit/includes/media/FormatMetadataTest.php')
-rw-r--r-- | tests/phpunit/includes/media/FormatMetadataTest.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/phpunit/includes/media/FormatMetadataTest.php b/tests/phpunit/includes/media/FormatMetadataTest.php new file mode 100644 index 00000000..db36dea3 --- /dev/null +++ b/tests/phpunit/includes/media/FormatMetadataTest.php @@ -0,0 +1,29 @@ +<?php +class FormatMetadataTest extends MediaWikiTestCase { + public function testInvalidDate() { + global $wgShowEXIF; + if ( !$wgShowEXIF ) { + $this->markTestIncomplete( "This test needs the exif extension." ); + } + + $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) . + '/../../data/media/broken_exif_date.jpg', 'image/jpeg' ); + + // Throws an error if bug hit + $meta = $file->formatMetadata(); + $this->assertNotEquals( false, $meta, 'Valid metadata extracted' ); + + // 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)' ); + } +}
\ No newline at end of file |