2 class FormatMetadataTest
extends MediaWikiTestCase
{
4 protected function setUp() {
7 if ( !wfDl( 'exif' ) ) {
8 $this->markTestSkipped( "This test needs the exif extension." );
10 $filePath = __DIR__
. '/../../data/media';
11 $this->backend
= new FSFileBackend( array(
12 'name' => 'localtesting',
13 'lockManager' => 'nullLockManager',
14 'containerPaths' => array( 'data' => $filePath )
16 $this->repo
= new FSRepo( array(
18 'url' => 'http://localhost/thumbtest',
19 'backend' => $this->backend
22 $this->setMwGlobals( 'wgShowEXIF', true );
25 public function testInvalidDate() {
26 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
28 // Throws an error if bug hit
29 $meta = $file->formatMetadata();
30 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
32 // Find date exif entry
33 $this->assertArrayHasKey( 'visible', $meta );
35 foreach ( $meta['visible'] as $i => $data ) {
36 if ( $data['id'] == 'exif-datetimeoriginal' ) {
40 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
41 $this->assertEquals( '0000:01:00 00:02:27',
42 $meta['visible'][$dateIndex]['value'],
43 'File with invalid date metadata (bug 29471)' );
46 private function dataFile( $name, $type ) {
47 return new UnregisteredLocalFile( false, $this->repo
,
48 "mwstore://localtesting/data/$name", $type );