From 14f74d141ab5580688bfd46d2f74c026e43ed967 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Apr 2015 06:11:44 +0200 Subject: Update to MediaWiki 1.24.2 --- .../phpunit/includes/media/FormatMetadataTest.php | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/phpunit/includes/media/FormatMetadataTest.php (limited to 'tests/phpunit/includes/media/FormatMetadataTest.php') diff --git a/tests/phpunit/includes/media/FormatMetadataTest.php b/tests/phpunit/includes/media/FormatMetadataTest.php new file mode 100644 index 00000000..002e2cb9 --- /dev/null +++ b/tests/phpunit/includes/media/FormatMetadataTest.php @@ -0,0 +1,71 @@ +checkPHPExtension( 'exif' ); + $this->setMwGlobals( 'wgShowEXIF', true ); + } + + /** + * @covers File::formatMetadata + */ + public function testInvalidDate() { + $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' ); + + // Throws an error if bug hit + $meta = $file->formatMetadata(); + $this->assertNotEquals( false, $meta, 'Valid metadata extracted' ); + + // Find date exif entry + $this->assertArrayHasKey( 'visible', $meta ); + $dateIndex = null; + foreach ( $meta['visible'] as $i => $data ) { + if ( $data['id'] == 'exif-datetimeoriginal' ) { + $dateIndex = $i; + } + } + $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' ); + $this->assertEquals( '0000:01:00 00:02:27', + $meta['visible'][$dateIndex]['value'], + 'File with invalid date metadata (bug 29471)' ); + } + + /** + * @param string $filename + * @param int $expected Total image area + * @dataProvider provideFlattenArray + * @covers FormatMetadata::flattenArray + */ + public function testFlattenArray( $vals, $type, $noHtml, $ctx, $expected ) { + $actual = FormatMetadata::flattenArray( $vals, $type, $noHtml, $ctx ); + $this->assertEquals( $expected, $actual ); + } + + public static function provideFlattenArray() { + return array( + array( + array( 1, 2, 3 ), 'ul', false, false, + "", + ), + array( + array( 1, 2, 3 ), 'ol', false, false, + "
  1. 1
  2. \n
  3. 2
  4. \n
  5. 3
", + ), + array( + array( 1, 2, 3 ), 'ul', true, false, + "\n*1\n*2\n*3", + ), + array( + array( 1, 2, 3 ), 'ol', true, false, + "\n#1\n#2\n#3", + ), + // TODO: more test cases + ); + } +} -- cgit v1.2.3-54-g00ecf