MediaWiki  REL1_22
GIFMetadataExtractorTest.php
Go to the documentation of this file.
00001 <?php
00002 class GIFMetadataExtractorTest extends MediaWikiTestCase {
00003 
00004     protected function setUp() {
00005         parent::setUp();
00006 
00007         $this->mediaPath = __DIR__ . '/../../data/media/';
00008     }
00009 
00017     public function testGetMetadata( $filename, $expected ) {
00018         $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
00019         $this->assertEquals( $expected, $actual );
00020     }
00021 
00022     public static function provideGetMetadata() {
00023 
00024         $xmpNugget = <<<EOF
00025 <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
00026 <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
00027 <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
00028 
00029  <rdf:Description rdf:about=''
00030   xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
00031   <Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
00032  </rdf:Description>
00033 
00034  <rdf:Description rdf:about=''
00035   xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
00036   <tiff:Artist>Bawolff</tiff:Artist>
00037   <tiff:ImageDescription>
00038    <rdf:Alt>
00039     <rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
00040    </rdf:Alt>
00041   </tiff:ImageDescription>
00042  </rdf:Description>
00043 </rdf:RDF>
00044 </x:xmpmeta>
00045                                                                                                     
00046                                                                                                     
00047                                                                                                     
00048                                                                                                     
00049                                                                                                     
00050                                                                                                     
00051                                                                                                     
00052                                                                                                     
00053                                                                                                     
00054                                                                                                     
00055                                                                                                     
00056                                                                                                     
00057                                                                                                     
00058                                                                                                     
00059                                                                                                     
00060                                                                                                     
00061                                                                                                     
00062                                                                                                     
00063                                                                                                     
00064                                                                                                     
00065                                                                                                     
00066                                                                                                     
00067                                                                                                     
00068                                                                                                     
00069 <?xpacket end='w'?>
00070 EOF;
00071         $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
00072 
00073         return array(
00074             array(
00075                 'nonanimated.gif',
00076                 array(
00077                     'comment' => array( 'GIF test file ⁕ Created with GIMP' ),
00078                     'duration' => 0.1,
00079                     'frameCount' => 1,
00080                     'looped' => false,
00081                     'xmp' => '',
00082                 )
00083             ),
00084             array(
00085                 'animated.gif',
00086                 array(
00087                     'comment' => array( 'GIF test file . Created with GIMP' ),
00088                     'duration' => 2.4,
00089                     'frameCount' => 4,
00090                     'looped' => true,
00091                     'xmp' => '',
00092                 )
00093             ),
00094 
00095             array(
00096                 'animated-xmp.gif',
00097                 array(
00098                     'xmp' => $xmpNugget,
00099                     'duration' => 2.4,
00100                     'frameCount' => 4,
00101                     'looped' => true,
00102                     'comment' => array( 'GIƒ·test·file' ),
00103                 )
00104             ),
00105         );
00106     }
00107 }