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