Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / media / GIFMetadataExtractorTest.php
blob1044e5210e003f93d9c672d520890a04d76be2a8
1 <?php
3 /**
4 * @group Media
5 */
6 class GIFMetadataExtractorTest extends MediaWikiTestCase {
8 protected function setUp() {
9 parent::setUp();
11 $this->mediaPath = __DIR__ . '/../../data/media/';
14 /**
15 * Put in a file, and see if the metadata coming out is as expected.
16 * @param string $filename
17 * @param array $expected The extracted metadata.
18 * @dataProvider provideGetMetadata
19 * @covers GIFMetadataExtractor::getMetadata
21 public function testGetMetadata( $filename, $expected ) {
22 $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
23 $this->assertEquals( $expected, $actual );
26 public static function provideGetMetadata() {
28 $xmpNugget = <<<EOF
29 <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
30 <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
31 <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
33 <rdf:Description rdf:about=''
34 xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
35 <Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
36 </rdf:Description>
38 <rdf:Description rdf:about=''
39 xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
40 <tiff:Artist>Bawolff</tiff:Artist>
41 <tiff:ImageDescription>
42 <rdf:Alt>
43 <rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
44 </rdf:Alt>
45 </tiff:ImageDescription>
46 </rdf:Description>
47 </rdf:RDF>
48 </x:xmpmeta>
73 <?xpacket end='w'?>
74 EOF;
75 $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
77 return [
79 'nonanimated.gif',
81 'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
82 'duration' => 0.1,
83 'frameCount' => 1,
84 'looped' => false,
85 'xmp' => '',
89 'animated.gif',
91 'comment' => [ 'GIF test file . Created with GIMP' ],
92 'duration' => 2.4,
93 'frameCount' => 4,
94 'looped' => true,
95 'xmp' => '',
100 'animated-xmp.gif',
102 'xmp' => $xmpNugget,
103 'duration' => 2.4,
104 'frameCount' => 4,
105 'looped' => true,
106 'comment' => [ 'GIƒ·test·file' ],