The point of this patch is to allow someone to use this class to get the metadata formatted in the language of their choice (by passing in an appropriate context object), instead of forcing $wgLang. This is important for future evil plans I have. To do this, some of the previous static methods were changed to non-static. I checked and fixed all users of such methods (including extensions). Some of the implied private methods were also explicitly marked as such. Change-Id: I673d99fa36280d1baf14c150f4aaff039676830a
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
class SVGTest extends MediaWikiTestCase {
|
|
|
|
protected function setUp() {
|
|
parent::setUp();
|
|
|
|
$this->filePath = __DIR__ . '/../../data/media/';
|
|
|
|
$this->setMwGlobals( 'wgShowEXIF', true );
|
|
|
|
$this->backend = new FSFileBackend( array(
|
|
'name' => 'localtesting',
|
|
'lockManager' => 'nullLockManager',
|
|
'containerPaths' => array( 'data' => $this->filePath )
|
|
) );
|
|
$this->repo = new FSRepo( array(
|
|
'name' => 'temp',
|
|
'url' => 'http://localhost/thumbtest',
|
|
'backend' => $this->backend
|
|
) );
|
|
|
|
$this->handler = new SVGHandler;
|
|
}
|
|
|
|
/**
|
|
* @param $filename String
|
|
* @param $expected Array The expected independent metadata
|
|
* @dataProvider providerGetIndependentMetaArray
|
|
* @covers SvgHandler::getCommonMetaArray
|
|
*/
|
|
public function testGetIndependentMetaArray( $filename, $expected ) {
|
|
$file = $this->dataFile( $filename, 'image/svg+xml' );
|
|
$res = $this->handler->getCommonMetaArray( $file );
|
|
|
|
$this->assertEquals( $res, $expected );
|
|
}
|
|
|
|
public function providerGetIndependentMetaArray() {
|
|
return array(
|
|
array( 'Tux.svg', array(
|
|
'ObjectName' => 'Tux',
|
|
'ImageDescription' => 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
|
|
) ),
|
|
array( 'Wikimedia-logo.svg', array() )
|
|
);
|
|
}
|
|
|
|
private function dataFile( $name, $type ) {
|
|
return new UnregisteredLocalFile( false, $this->repo,
|
|
"mwstore://localtesting/data/$name", $type );
|
|
}
|
|
}
|