b68dd0ee0a11b95669b96d8ba59c03c2fda407b9
6 class SVGTest
extends MediaWikiMediaTestCase
{
13 protected function setUp() {
16 $this->filePath
= __DIR__
. '/../../data/media/';
18 $this->setMwGlobals( 'wgShowEXIF', true );
20 $this->handler
= new SvgHandler
;
24 * @param string $filename
25 * @param array $expected The expected independent metadata
26 * @dataProvider providerGetIndependentMetaArray
27 * @covers SvgHandler::getCommonMetaArray
29 public function testGetIndependentMetaArray( $filename, $expected ) {
30 $file = $this->dataFile( $filename, 'image/svg+xml' );
31 $res = $this->handler
->getCommonMetaArray( $file );
33 $this->assertEquals( $res, $expected );
36 public static function providerGetIndependentMetaArray() {
39 'ObjectName' => 'Tux',
41 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
43 [ 'Wikimedia-logo.svg', [] ]
48 * @param string $userPreferredLanguage
49 * @param array $svgLanguages
50 * @param string $expectedMatch
51 * @dataProvider providerGetMatchedLanguage
52 * @covers SvgHandler::getMatchedLanguage
54 public function testGetMatchedLanguage( $userPreferredLanguage, $svgLanguages, $expectedMatch ) {
55 $match = $this->handler
->getMatchedLanguage( $userPreferredLanguage, $svgLanguages );
56 $this->assertEquals( $expectedMatch, $match );
59 public function providerGetMatchedLanguage() {
62 'userPreferredLanguage' => 'en',
63 'svgLanguages' => [ 'de-DE', 'zh', 'ga', 'fr', 'sr-Latn-ME' ],
64 'expectedMatch' => null,
67 'userPreferredLanguage' => 'en',
68 'svgLanguages' => [ 'de', 'zh', 'en', 'fr' ],
69 'expectedMatch' => 'en',
71 'user no subtags, svg 1 subtag' => [
72 'userPreferredLanguage' => 'en',
73 'svgLanguages' => [ 'de-DE', 'en-GB', 'en-US', 'fr' ],
74 'expectedMatch' => 'en-GB',
76 'user no subtags, svg >1 subtag' => [
77 'userPreferredLanguage' => 'sr',
78 'svgLanguages' => [ 'de-DE', 'sr-Cyrl-BA', 'sr-Latn-ME', 'en-US', 'fr' ],
79 'expectedMatch' => 'sr-Cyrl-BA',
81 'user 1 subtag, svg no subtags' => [
82 'userPreferredLanguage' => 'en-US',
83 'svgLanguages' => [ 'de', 'en', 'en', 'fr' ],
84 'expectedMatch' => null,
86 'user 1 subtag, svg 1 subtag' => [
87 'userPreferredLanguage' => 'en-US',
88 'svgLanguages' => [ 'de-DE', 'en-GB', 'en-US', 'fr' ],
89 'expectedMatch' => 'en-US',
91 'user 1 subtag, svg >1 subtag' => [
92 'userPreferredLanguage' => 'sr-Latn',
93 'svgLanguages' => [ 'de-DE', 'sr-Cyrl-BA', 'sr-Latn-ME', 'fr' ],
94 'expectedMatch' => 'sr-Latn-ME',
96 'user >1 subtag, svg >1 subtag' => [
97 'userPreferredLanguage' => 'sr-Latn-ME',
98 'svgLanguages' => [ 'de-DE', 'sr-Cyrl-BA', 'sr-Latn-ME', 'en-US', 'fr' ],
99 'expectedMatch' => 'sr-Latn-ME',
101 'user >1 subtag, svg <=1 subtag' => [
102 'userPreferredLanguage' => 'sr-Latn-ME',
103 'svgLanguages' => [ 'de-DE', 'sr-Cyrl', 'sr-Latn', 'en-US', 'fr' ],
104 'expectedMatch' => null,
106 'ensure case-insensitive' => [
107 'userPreferredLanguage' => 'sr-latn',
108 'svgLanguages' => [ 'de-DE', 'sr-Cyrl', 'sr-Latn-ME', 'en-US', 'fr' ],
109 'expectedMatch' => 'sr-Latn-ME',