Fixed dependencies for jquery.collapsibleTabs
[lhc/web/wiklou.git] / tests / phpunit / includes / media / FormatMetadataTest.php
1 <?php
2 class FormatMetadataTest extends MediaWikiTestCase {
3 public function setUp() {
4 if ( !wfDl( 'exif' ) ) {
5 $this->markTestSkipped( "This test needs the exif extension." );
6 }
7 $filePath = __DIR__ . '/../../data/media';
8 $this->backend = new FSFileBackend( array(
9 'name' => 'localtesting',
10 'lockManager' => 'nullLockManager',
11 'containerPaths' => array( 'data' => $filePath )
12 ) );
13 $this->repo = new FSRepo( array(
14 'name' => 'temp',
15 'url' => 'http://localhost/thumbtest',
16 'backend' => $this->backend
17 ) );
18 global $wgShowEXIF;
19 $this->show = $wgShowEXIF;
20 $wgShowEXIF = true;
21 }
22 public function tearDown() {
23 global $wgShowEXIF;
24 $wgShowEXIF = $this->show;
25 }
26
27 public function testInvalidDate() {
28 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
29
30 // Throws an error if bug hit
31 $meta = $file->formatMetadata();
32 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
33
34 // Find date exif entry
35 $this->assertArrayHasKey( 'visible', $meta );
36 $dateIndex = null;
37 foreach ( $meta['visible'] as $i => $data ) {
38 if ( $data['id'] == 'exif-datetimeoriginal' ) {
39 $dateIndex = $i;
40 }
41 }
42 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
43 $this->assertEquals( '0000:01:00 00:02:27',
44 $meta['visible'][$dateIndex]['value'],
45 'File with invalid date metadata (bug 29471)' );
46 }
47
48 private function dataFile( $name, $type ) {
49 return new UnregisteredLocalFile( false, $this->repo,
50 "mwstore://localtesting/data/$name", $type );
51 }
52 }