6 class FormatMetadataTest
extends MediaWikiTestCase
{
8 /** @var FSFileBackend */
13 protected function setUp() {
16 if ( !extension_loaded( 'exif' ) ) {
17 $this->markTestSkipped( "This test needs the exif extension." );
19 $filePath = __DIR__
. '/../../data/media';
20 $this->backend
= new FSFileBackend( array(
21 'name' => 'localtesting',
22 'lockManager' => 'nullLockManager',
23 'containerPaths' => array( 'data' => $filePath )
25 $this->repo
= new FSRepo( array(
27 'url' => 'http://localhost/thumbtest',
28 'backend' => $this->backend
31 $this->setMwGlobals( 'wgShowEXIF', true );
34 public function testInvalidDate() {
35 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
37 // Throws an error if bug hit
38 $meta = $file->formatMetadata();
39 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
41 // Find date exif entry
42 $this->assertArrayHasKey( 'visible', $meta );
44 foreach ( $meta['visible'] as $i => $data ) {
45 if ( $data['id'] == 'exif-datetimeoriginal' ) {
49 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
50 $this->assertEquals( '0000:01:00 00:02:27',
51 $meta['visible'][$dateIndex]['value'],
52 'File with invalid date metadata (bug 29471)' );
55 private function dataFile( $name, $type ) {
56 return new UnregisteredLocalFile( false, $this->repo
,
57 "mwstore://localtesting/data/$name", $type );