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