Go to the documentation of this file.
3 use Wikimedia\TestingAccessWrapper;
18 $this->filePath = __DIR__ .
'/../../data/media/';
25 self::assertEquals(
$res, $expected );
31 'ObjectName' =>
'Tux',
33 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
35 [
'Wikimedia-logo.svg', [] ]
49 $match =
$handler->getMatchedLanguage( $userPreferredLanguage, $svgLanguages );
50 self::assertEquals( $expectedMatch, $match );
56 'userPreferredLanguage' =>
'en',
57 'svgLanguages' => [
'de-DE',
'zh',
'ga',
'fr',
'sr-Latn-ME' ],
58 'expectedMatch' =>
null,
61 'userPreferredLanguage' =>
'en',
62 'svgLanguages' => [
'de',
'zh',
'en',
'fr' ],
63 'expectedMatch' =>
'en',
65 'user no subtags, svg 1 subtag' => [
66 'userPreferredLanguage' =>
'en',
67 'svgLanguages' => [
'de-DE',
'en-GB',
'en-US',
'fr' ],
68 'expectedMatch' =>
'en-GB',
70 'user no subtags, svg >1 subtag' => [
71 'userPreferredLanguage' =>
'sr',
72 'svgLanguages' => [
'de-DE',
'sr-Cyrl-BA',
'sr-Latn-ME',
'en-US',
'fr' ],
73 'expectedMatch' =>
'sr-Cyrl-BA',
75 'user 1 subtag, svg no subtags' => [
76 'userPreferredLanguage' =>
'en-US',
77 'svgLanguages' => [
'de',
'en',
'en',
'fr' ],
78 'expectedMatch' =>
null,
80 'user 1 subtag, svg 1 subtag' => [
81 'userPreferredLanguage' =>
'en-US',
82 'svgLanguages' => [
'de-DE',
'en-GB',
'en-US',
'fr' ],
83 'expectedMatch' =>
'en-US',
85 'user 1 subtag, svg >1 subtag' => [
86 'userPreferredLanguage' =>
'sr-Latn',
87 'svgLanguages' => [
'de-DE',
'sr-Cyrl-BA',
'sr-Latn-ME',
'fr' ],
88 'expectedMatch' =>
'sr-Latn-ME',
90 'user >1 subtag, svg >1 subtag' => [
91 'userPreferredLanguage' =>
'sr-Latn-ME',
92 'svgLanguages' => [
'de-DE',
'sr-Cyrl-BA',
'sr-Latn-ME',
'en-US',
'fr' ],
93 'expectedMatch' =>
'sr-Latn-ME',
95 'user >1 subtag, svg <=1 subtag' => [
96 'userPreferredLanguage' =>
'sr-Latn-ME',
97 'svgLanguages' => [
'de-DE',
'sr-Cyrl',
'sr-Latn',
'en-US',
'fr' ],
98 'expectedMatch' =>
null,
100 'ensure case-insensitive' => [
101 'userPreferredLanguage' =>
'sr-latn',
102 'svgLanguages' => [
'de-DE',
'sr-Cyrl',
'sr-Latn-ME',
'en-US',
'fr' ],
103 'expectedMatch' =>
'sr-Latn-ME',
118 self::assertEquals( $expected,
$handler->makeParamString(
$params ), $message );
126 "Don't thumbnail without knowing width"
131 "Don't thumbnail without knowing width, even with lang"
139 [
'width' => 123,
'lang' =>
'en' ],
144 [
'width' => 123,
'targetlang' =>
'en' ],
146 'Ignore targetlang=en'
149 [
'width' => 123,
'lang' =>
'en',
'targetlang' =>
'ru' ],
151 "lang should override targetlang even of it's in English"
154 [
'width' => 123,
'targetlang' =>
'en' ],
156 'Ignore targetlang=en'
159 [
'width' => 123,
'lang' =>
'en',
'targetlang' =>
'en' ],
161 'Ignore lang=targetlang=en'
164 [
'width' => 123,
'lang' =>
'ru' ],
166 'Include lang in thumb'
169 [
'width' => 123,
'targetlang' =>
'ru' ],
171 'Include targetlang in thumb'
174 [
'width' => 123,
'lang' =>
'fr',
'targetlang' =>
'sq' ],
176 'lang should override targetlang'
195 array $paramsExpected =
null
203 ->disableOriginalConstructor()
204 ->setMethods( [
'getWidth',
'getHeight',
'getMetadata',
'getHandler' ] )
207 $file->method(
'getWidth' )
208 ->willReturn( $width );
209 $file->method(
'getHeight' )
210 ->willReturn( $height );
211 $file->method(
'getMetadata' )
219 $file->method(
'getHandler' )
224 self::assertEquals( $paramsExpected,
$params, $message );
230 'No need to change anything',
232 [
'physicalWidth' => 400,
'physicalHeight' => 500 ],
233 [
'physicalWidth' => 400,
'physicalHeight' => 500 ],
236 'Resize horizontal image',
238 [
'physicalWidth' => 2000,
'physicalHeight' => 1600,
'page' => 0 ],
239 [
'physicalWidth' => 1250,
'physicalHeight' => 1000,
'page' => 0 ],
242 'Resize vertical image',
244 [
'physicalWidth' => 1600,
'physicalHeight' => 2000,
'page' => 0 ],
245 [
'physicalWidth' => 1000,
'physicalHeight' => 1250,
'page' => 0 ],
248 'Preserve targetlang present in the image',
250 [
'physicalWidth' => 400,
'physicalHeight' => 500,
'targetlang' =>
'en' ],
251 [
'physicalWidth' => 400,
'physicalHeight' => 500,
'targetlang' =>
'en' ],
254 'Preserve targetlang present in the image 2',
256 [
'physicalWidth' => 400,
'physicalHeight' => 500,
'targetlang' =>
'en' ],
257 [
'physicalWidth' => 400,
'physicalHeight' => 500,
'targetlang' =>
'en' ],
260 'Remove targetlang not present in the image',
262 [
'physicalWidth' => 400,
'physicalHeight' => 500,
'targetlang' =>
'de' ],
263 [
'physicalWidth' => 400,
'physicalHeight' => 500 ],
266 'Remove targetlang not present in the image 2',
268 [
'physicalWidth' => 400,
'physicalHeight' => 500,
'targetlang' =>
'ru-UA' ],
269 [
'physicalWidth' => 400,
'physicalHeight' => 500 ],
285 self::assertEquals(
$handler->isEnabled(), $expected );
290 [
'ImageMagick',
true ],
291 [
'sodipodi',
true ],
292 [
'invalid',
false ],
306 ->disableOriginalConstructor()
307 ->setMethods( [
'getMetadata' ] )
309 $file->method(
'getMetadata' )
314 self::assertEquals( $expected,
$handler->getAvailableLanguages(
$file ) );
320 [ [
'translations' => [] ], [] ],
354 self::assertEquals( $expected,
$handler->getLanguageFromParams(
$params ), $message );
359 [ [],
'en',
'Default no language to en' ],
360 [ [
'preserve' =>
'this' ],
'en',
'Default no language to en 2' ],
361 [ [
'preserve' =>
'this',
'lang' =>
'ru' ],
'ru',
'Language from lang' ],
362 [ [
'lang' =>
'ru' ],
'ru',
'Language from lang 2' ],
363 [ [
'targetlang' =>
'fr' ],
'fr',
'Language from targetlang' ],
364 [ [
'lang' =>
'fr',
'targetlang' =>
'de' ],
'fr',
'lang overrides targetlang' ],
provideAvailableLanguages()
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
processing should stop and the error should be shown to the user * false
testGetAvailableLanguages(array $metadata, array $expected)
\SvgHandler::getAvailableLanguages() provideAvailableLanguages
testGetMatchedLanguage( $userPreferredLanguage, $svgLanguages, $expectedMatch)
SvgHandler::getMatchedLanguage() provideGetMatchedLanguage.
provideGetMatchedLanguage()
provideGetLanguageFromParams()
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
testGetIndependentMetaArray( $filename, $expected)
\SvgHandler::getCommonMetaArray() provideGetIndependentMetaArray
testMakeParamString(array $params, $expected, $message='')
\SvgHandler::makeParamString() provideMakeParamString
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
testGetLanguageFromParams(array $params, $expected, $message)
SvgHandler::getLanguageFromParams() provideGetLanguageFromParams.
provideNormaliseParamsInternal()
static provideGetIndependentMetaArray()
testNormaliseParamsInternal( $message, $width, $height, array $params, array $paramsExpected=null)
SvgHandler::normaliseParamsInternal() provideNormaliseParamsInternal.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
testIsEnabled( $converter, $expected)
\SvgHandler::isEnabled() provideIsEnabled
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
const SVG_METADATA_VERSION