Merge "ApiSandbox: Indicate when login is suppressed"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / GIFMetadataExtractorTest.php
1 <?php
2
3 /**
4 * @group Media
5 */
6 class GIFMetadataExtractorTest extends MediaWikiTestCase {
7
8 protected function setUp() {
9 parent::setUp();
10
11 $this->mediaPath = __DIR__ . '/../../data/media/';
12 }
13
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
20 */
21 public function testGetMetadata( $filename, $expected ) {
22 $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
23 $this->assertEquals( $expected, $actual );
24 }
25
26 public static function provideGetMetadata() {
27
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#'>
32
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>
37
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>
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 <?xpacket end='w'?>
74 EOF;
75 $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
76
77 return [
78 [
79 'nonanimated.gif',
80 [
81 'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
82 'duration' => 0.1,
83 'frameCount' => 1,
84 'looped' => false,
85 'xmp' => '',
86 ]
87 ],
88 [
89 'animated.gif',
90 [
91 'comment' => [ 'GIF test file . Created with GIMP' ],
92 'duration' => 2.4,
93 'frameCount' => 4,
94 'looped' => true,
95 'xmp' => '',
96 ]
97 ],
98
99 [
100 'animated-xmp.gif',
101 [
102 'xmp' => $xmpNugget,
103 'duration' => 2.4,
104 'frameCount' => 4,
105 'looped' => true,
106 'comment' => [ 'GIƒ·test·file' ],
107 ]
108 ],
109 ];
110 }
111 }