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