MediaWiki
REL1_21
|
00001 <?php 00002 class FormatMetadataTest extends MediaWikiTestCase { 00003 00004 protected function setUp() { 00005 parent::setUp(); 00006 00007 if ( !wfDl( 'exif' ) ) { 00008 $this->markTestSkipped( "This test needs the exif extension." ); 00009 } 00010 $filePath = __DIR__ . '/../../data/media'; 00011 $this->backend = new FSFileBackend( array( 00012 'name' => 'localtesting', 00013 'lockManager' => 'nullLockManager', 00014 'containerPaths' => array( 'data' => $filePath ) 00015 ) ); 00016 $this->repo = new FSRepo( array( 00017 'name' => 'temp', 00018 'url' => 'http://localhost/thumbtest', 00019 'backend' => $this->backend 00020 ) ); 00021 00022 $this->setMwGlobals( 'wgShowEXIF', true ); 00023 } 00024 00025 public function testInvalidDate() { 00026 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' ); 00027 00028 // Throws an error if bug hit 00029 $meta = $file->formatMetadata(); 00030 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' ); 00031 00032 // Find date exif entry 00033 $this->assertArrayHasKey( 'visible', $meta ); 00034 $dateIndex = null; 00035 foreach ( $meta['visible'] as $i => $data ) { 00036 if ( $data['id'] == 'exif-datetimeoriginal' ) { 00037 $dateIndex = $i; 00038 } 00039 } 00040 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' ); 00041 $this->assertEquals( '0000:01:00 00:02:27', 00042 $meta['visible'][$dateIndex]['value'], 00043 'File with invalid date metadata (bug 29471)' ); 00044 } 00045 00046 private function dataFile( $name, $type ) { 00047 return new UnregisteredLocalFile( false, $this->repo, 00048 "mwstore://localtesting/data/$name", $type ); 00049 } 00050 }