3 class SVGMetadataExtractorTest
extends MediaWikiTestCase
{
6 AutoLoader
::loadClass( 'SVGMetadataExtractorTest' );
10 * @dataProvider providerSvgFiles
12 function testGetMetadata( $infile, $expected ) {
13 $this->assertMetadata( $infile, $expected );
17 * @dataProvider providerSvgFilesWithXMLMetadata
19 function testGetXMLMetadata( $infile, $expected ) {
21 if( !method_exists( $r, 'readInnerXML' ) ) {
22 $this->markTestSkipped( 'XMLReader::readInnerXML() does not exist (libxml >2.6.20 needed).' );
25 $this->assertMetadata( $infile, $expected );
28 function assertMetadata( $infile, $expected ) {
30 $data = SVGMetadataExtractor
::getMetadata( $infile );
31 $this->assertEquals( $expected, $data, 'SVG metadata extraction test' );
32 } catch ( MWException
$e ) {
33 if ( $expected === false ) {
34 $this->assertTrue( true, 'SVG metadata extracted test (expected failure)' );
41 function providerSvgFiles() {
42 $base = __DIR__
. '/../../data/media';
45 "$base/Wikimedia-logo.svg",
49 'originalWidth' => '1024',
50 'originalHeight' => '1024',
58 'originalWidth' => '60',
59 'originalHeight' => '60',
63 "$base/Gtk-media-play-ltr.svg",
67 'originalWidth' => '60.0000000',
68 'originalHeight' => '60.0000000',
72 "$base/Toll_Texas_1.svg",
73 // This file triggered bug 31719, needs entity expansion in the xmlns checks
77 'originalWidth' => '385',
78 'originalHeight' => '385.0004883',
84 function providerSvgFilesWithXMLMetadata() {
85 $base = __DIR__
. '/../../data/media';
87 '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
88 <ns4:Work xmlns:ns4="http://creativecommons.org/ns#" rdf:about="">
89 <ns5:format xmlns:ns5="http://purl.org/dc/elements/1.1/">image/svg+xml</ns5:format>
90 <ns5:type xmlns:ns5="http://purl.org/dc/elements/1.1/" rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
93 $metadata = str_replace( "\r", '', $metadata ); // Windows compat
96 "$base/US_states_by_total_state_tax_revenue.svg",
99 'metadata' => $metadata,
101 'originalWidth' => '958.69',
102 'originalHeight' => '592.78998',