MediaWiki  1.33.0
GIFMetadataExtractorTest.php
Go to the documentation of this file.
1 <?php
2 
6 class GIFMetadataExtractorTest extends MediaWikiTestCase {
7 
8  protected function setUp() {
9  parent::setUp();
10 
11  $this->mediaPath = __DIR__ . '/../../data/media/';
12  }
13 
21  public function testGetMetadata( $filename, $expected ) {
22  $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
23  $this->assertEquals( $expected, $actual );
24  }
25 
26  public static function provideGetMetadata() {
27  $xmpNugget = <<<EOF
28 <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
29 <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
30 <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
31 
32  <rdf:Description rdf:about=''
33  xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
34  <Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
35  </rdf:Description>
36 
37  <rdf:Description rdf:about=''
38  xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
39  <tiff:Artist>Bawolff</tiff:Artist>
40  <tiff:ImageDescription>
41  <rdf:Alt>
42  <rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
43  </rdf:Alt>
44  </tiff:ImageDescription>
45  </rdf:Description>
46 </rdf:RDF>
47 </x:xmpmeta>
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 <?xpacket end='w'?>
73 EOF;
74  $xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
75 
76  return [
77  [
78  'nonanimated.gif',
79  [
80  'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
81  'duration' => 0.1,
82  'frameCount' => 1,
83  'looped' => false,
84  'xmp' => '',
85  ]
86  ],
87  [
88  'animated.gif',
89  [
90  'comment' => [ 'GIF test file . Created with GIMP' ],
91  'duration' => 2.4,
92  'frameCount' => 4,
93  'looped' => true,
94  'xmp' => '',
95  ]
96  ],
97 
98  [
99  'animated-xmp.gif',
100  [
101  'xmp' => $xmpNugget,
102  'duration' => 2.4,
103  'frameCount' => 4,
104  'looped' => true,
105  'comment' => [ 'GIƒ·test·file' ],
106  ]
107  ],
108  ];
109  }
110 }
file
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:91
about
span about
Definition: parserTests.txt:18481
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWikiTestCase
Definition: MediaWikiTestCase.php:17
GIFMetadataExtractor\getMetadata
static getMetadata( $filename)
Definition: GIFMetadataExtractor.php:56
begin
$dbw begin(__METHOD__)
MediaWikiTestCase\setUp
setUp()
Definition: MediaWikiTestCase.php:504