Escape backticks when quoting MySQL identifiers
[lhc/web/wiklou.git] / tests / phpunit / includes / media / FormatMetadataTest.php
1 <?php
2 class FormatMetadataTest extends MediaWikiTestCase {
3
4 protected function setUp() {
5 parent::setUp();
6
7 if ( !wfDl( 'exif' ) ) {
8 $this->markTestSkipped( "This test needs the exif extension." );
9 }
10 $filePath = __DIR__ . '/../../data/media';
11 $this->backend = new FSFileBackend( array(
12 'name' => 'localtesting',
13 'lockManager' => 'nullLockManager',
14 'containerPaths' => array( 'data' => $filePath )
15 ) );
16 $this->repo = new FSRepo( array(
17 'name' => 'temp',
18 'url' => 'http://localhost/thumbtest',
19 'backend' => $this->backend
20 ) );
21
22 $this->setMwGlobals( 'wgShowEXIF', true );
23 }
24
25 public function testInvalidDate() {
26 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
27
28 // Throws an error if bug hit
29 $meta = $file->formatMetadata();
30 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
31
32 // Find date exif entry
33 $this->assertArrayHasKey( 'visible', $meta );
34 $dateIndex = null;
35 foreach ( $meta['visible'] as $i => $data ) {
36 if ( $data['id'] == 'exif-datetimeoriginal' ) {
37 $dateIndex = $i;
38 }
39 }
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)' );
44 }
45
46 private function dataFile( $name, $type ) {
47 return new UnregisteredLocalFile( false, $this->repo,
48 "mwstore://localtesting/data/$name", $type );
49 }
50 }