Merge "Pass phpcs-strict on some test files (9/11)"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / SVGTest.php
1 <?php
2
3 class SvgTest extends MediaWikiTestCase {
4
5 protected function setUp() {
6 parent::setUp();
7
8 $this->filePath = __DIR__ . '/../../data/media/';
9
10 $this->setMwGlobals( 'wgShowEXIF', true );
11
12 $this->backend = new FSFileBackend( array(
13 'name' => 'localtesting',
14 'wikiId' => wfWikiId(),
15 'containerPaths' => array( 'data' => $this->filePath )
16 ) );
17 $this->repo = new FSRepo( array(
18 'name' => 'temp',
19 'url' => 'http://localhost/thumbtest',
20 'backend' => $this->backend
21 ) );
22
23 $this->handler = new SvgHandler;
24 }
25
26 /**
27 * @param string $filename
28 * @param array $expected The expected independent metadata
29 * @dataProvider providerGetIndependentMetaArray
30 * @covers SvgHandler::getCommonMetaArray
31 */
32 public function testGetIndependentMetaArray( $filename, $expected ) {
33 $file = $this->dataFile( $filename, 'image/svg+xml' );
34 $res = $this->handler->getCommonMetaArray( $file );
35
36 $this->assertEquals( $res, $expected );
37 }
38
39 public function providerGetIndependentMetaArray() {
40 return array(
41 array( 'Tux.svg', array(
42 'ObjectName' => 'Tux',
43 'ImageDescription' =>
44 'For more information see: http://commons.wikimedia.org/wiki/Image:Tux.svg',
45 ) ),
46 array( 'Wikimedia-logo.svg', array() )
47 );
48 }
49
50 private function dataFile( $name, $type ) {
51 return new UnregisteredLocalFile( false, $this->repo,
52 "mwstore://localtesting/data/$name", $type );
53 }
54 }