3 class FormatMetadataTest
extends MediaWikiMediaTestCase
{
5 protected function setUp() {
8 $this->checkPHPExtension( 'exif' );
9 $this->setMwGlobals( 'wgShowEXIF', true );
13 * @covers File::formatMetadata
15 public function testInvalidDate() {
16 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
18 // Throws an error if bug hit
19 $meta = $file->formatMetadata();
20 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
22 // Find date exif entry
23 $this->assertArrayHasKey( 'visible', $meta );
25 foreach ( $meta['visible'] as $i => $data ) {
26 if ( $data['id'] == 'exif-datetimeoriginal' ) {
30 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
31 $this->assertEquals( '0000:01:00 00:02:27',
32 $meta['visible'][$dateIndex]['value'],
33 'File with invalid date metadata (bug 29471)' );
37 * @param string $filename
38 * @param int $expected Total image area
39 * @dataProvider provideFlattenArray
40 * @covers FormatMetadata::flattenArray
42 public function testFlattenArray( $vals, $type, $noHtml, $ctx, $expected ) {
43 $actual = FormatMetadata
::flattenArray( $vals, $type, $noHtml, $ctx );
44 $this->assertEquals( $expected, $actual );
47 public static function provideFlattenArray() {
50 array( 1, 2, 3 ), 'ul', false, false,
51 "<ul><li>1</li>\n<li>2</li>\n<li>3</li></ul>",
54 array( 1, 2, 3 ), 'ol', false, false,
55 "<ol><li>1</li>\n<li>2</li>\n<li>3</li></ol>",
58 array( 1, 2, 3 ), 'ul', true, false,
62 array( 1, 2, 3 ), 'ol', true, false,
65 // TODO: more test cases