~ubuntu-branches/ubuntu/trusty/mediawiki/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/phpunit/includes/media/GIFMetadataExtractorTest.php

  • Committer: Package Import Robot
  • Author(s): Thorsten Glaser
  • Date: 2014-03-28 09:56:29 UTC
  • mfrom: (1.3.14)
  • Revision ID: package-import@ubuntu.com-20140328095629-1526y9tchdd507id
Tags: 1:1.19.14+dfsg-1
* New upstream security fix release (Closes: #742857):
  - (bug 62497) SECURITY: Add CSRF token on Special:ChangePassword
  - (bug 62467) Set a title for the context during import on the cli
* Use upstream-provided signing key bundle

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
                $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
 
67
 
 
68
                return array(
 
69
                        array( 'nonanimated.gif', array(
 
70
                                'comment' => array( 'GIF test file ⁕ Created with GIMP' ),
 
71
                                'duration' => 0.1,
 
72
                                'frameCount' => 1,
 
73
                                'looped' => false,
 
74
                                'xmp' => '',
 
75
                                )
 
76
                        ),
 
77
                        array( 'animated.gif', array(
 
78
                                'comment' => array( 'GIF test file . Created with GIMP' ),
 
79
                                'duration' => 2.4,
 
80
                                'frameCount' => 4,
 
81
                                'looped' => true,
 
82
                                'xmp' => '',
 
83
                                )
 
84
                        ),
 
85
 
 
86
                        array( 'animated-xmp.gif', array(
 
87
                                'xmp' => $xmpNugget,
 
88
                                'duration' => 2.4,
 
89
                                'frameCount' => 4,
 
90
                                'looped' => true,
 
91
                                'comment' => array( 'GIƒ·test·file' ),
 
92
                                )
 
93
                        ),
 
94
                );
 
95
        }
 
96
}