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