Debian Codegraph @

tests/phpunit/unit/includes/media/GIFMetadataExtractorTest.php

raw symbols SCIP
1 <?php
2
3 /**
4 * @group Media
5 */
6 class GIFMetadataExtractorTest extends \MediaWikiUnitTestCase {
7 private const FILE_PATH = __DIR__ . '/../../../data/media/';
8
9 /**
10 * Put in a file, and see if the metadata coming out is as expected.
11 * @param string $filename
12 * @param array $expected The extracted metadata.
13 * @dataProvider provideGetMetadata
14 * @covers \GIFMetadataExtractor::getMetadata
15 */
16 public function testGetMetadata( $filename, $expected ) {
17 $actual = GIFMetadataExtractor::getMetadata( self::FILE_PATH . $filename );
18 $this->assertEquals( $expected, $actual );
19 }
20
21 public static function provideGetMetadata() {
22 $xmpNugget = <<<EOF
23 <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
24 <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
25 <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
26
27 <rdf:Description rdf:about=''
28 xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
29 <Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
30 </rdf:Description>
31
32 <rdf:Description rdf:about=''
33 xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
34 <tiff:Artist>Bawolff</tiff:Artist>
35 <tiff:ImageDescription>
36 <rdf:Alt>
37 <rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
38 </rdf:Alt>
39 </tiff:ImageDescription>
40 </rdf:Description>
41 </rdf:RDF>
42 </x:xmpmeta>
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 <?xpacket end='w'?>
68 EOF;
69 $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
70
71 return [
72 [
73 'nonanimated.gif',
74 [
75 'width' => 45,
76 'height' => 30,
77 'bits' => 1,
78 'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
79 'duration' => 0.1,
80 'frameCount' => 1,
81 'looped' => false,
82 'xmp' => '',
83 ]
84 ],
85 [
86 'animated.gif',
87 [
88 'width' => 45,
89 'height' => 30,
90 'bits' => 1,
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 'width' => 45,
103 'height' => 30,
104 'bits' => 1,
105 'xmp' => $xmpNugget,
106 'duration' => 2.4,
107 'frameCount' => 4,
108 'looped' => true,
109 'comment' => [ 'GIƒ·test·file' ],
110 ]
111 ],
112 ];
113 }
114 }