test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / media / FormatMetadataTest.php
blobf26d27eedfea1438860c71b1f276a7bbd9f310db
1 <?php
2 class FormatMetadataTest extends MediaWikiTestCase {
4 protected function setUp() {
5 parent::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 )
15 ) );
16 $this->repo = new FSRepo( array(
17 'name' => 'temp',
18 'url' => 'http://localhost/thumbtest',
19 'backend' => $this->backend
20 ) );
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 );
34 $dateIndex = null;
35 foreach ( $meta['visible'] as $i => $data ) {
36 if ( $data['id'] == 'exif-datetimeoriginal' ) {
37 $dateIndex = $i;
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 );