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