MediaWiki
REL1_24
|
00001 <?php 00002 00006 class FormatMetadataTest extends MediaWikiMediaTestCase { 00007 00008 protected function setUp() { 00009 parent::setUp(); 00010 00011 $this->checkPHPExtension( 'exif' ); 00012 $this->setMwGlobals( 'wgShowEXIF', true ); 00013 } 00014 00018 public function testInvalidDate() { 00019 $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' ); 00020 00021 // Throws an error if bug hit 00022 $meta = $file->formatMetadata(); 00023 $this->assertNotEquals( false, $meta, 'Valid metadata extracted' ); 00024 00025 // Find date exif entry 00026 $this->assertArrayHasKey( 'visible', $meta ); 00027 $dateIndex = null; 00028 foreach ( $meta['visible'] as $i => $data ) { 00029 if ( $data['id'] == 'exif-datetimeoriginal' ) { 00030 $dateIndex = $i; 00031 } 00032 } 00033 $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' ); 00034 $this->assertEquals( '0000:01:00 00:02:27', 00035 $meta['visible'][$dateIndex]['value'], 00036 'File with invalid date metadata (bug 29471)' ); 00037 } 00038 00045 public function testFlattenArray( $vals, $type, $noHtml, $ctx, $expected ) { 00046 $actual = FormatMetadata::flattenArray( $vals, $type, $noHtml, $ctx ); 00047 $this->assertEquals( $expected, $actual ); 00048 } 00049 00050 public static function provideFlattenArray() { 00051 return array( 00052 array( 00053 array( 1, 2, 3 ), 'ul', false, false, 00054 "<ul><li>1</li>\n<li>2</li>\n<li>3</li></ul>", 00055 ), 00056 array( 00057 array( 1, 2, 3 ), 'ol', false, false, 00058 "<ol><li>1</li>\n<li>2</li>\n<li>3</li></ol>", 00059 ), 00060 array( 00061 array( 1, 2, 3 ), 'ul', true, false, 00062 "\n*1\n*2\n*3", 00063 ), 00064 array( 00065 array( 1, 2, 3 ), 'ol', true, false, 00066 "\n#1\n#2\n#3", 00067 ), 00068 // TODO: more test cases 00069 ); 00070 } 00071 }