Add wfUnserialize() wrapper around unserialize to prevent E_NOTICE and use it in...
[lhc/web/wiklou.git] / tests / phpunit / includes / media / FormatMetadataTest.php
1 <?php
2 class FormatMetadataTest extends MediaWikiTestCase {
3 public function testInvalidDate() {
4 global $wgShowEXIF;
5 if ( !$wgShowEXIF ) {
6 $this->markTestIncomplete( "This test needs the exif extension." );
7 }
8
9 $file = UnregisteredLocalFile::newFromPath( dirname( __FILE__ ) .
10 '/broken_exif_date.jpg', 'image/jpeg' );
11
12 // Throws an error if bug hit
13 $meta = $file->formatMetadata();
14 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
15
16 // Find date exif entry
17 $this->assertArrayHasKey( 'visible', $meta );
18 $dateIndex = null;
19 foreach ( $meta['visible'] as $i => $data ) {
20 if ( $data['id'] == 'exif-datetimeoriginal' ) {
21 $dateIndex = $i;
22 }
23 }
24 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
25 $this->assertEquals( '0000:01:00 00:02:27',
26 $meta['visible'][$dateIndex]['value'],
27 'File with invalid date metadata (bug 29471)' );
28 }
29 }