* upgrade patches for oracle 1.17->1.19
[mediawiki.git] / tests / phpunit / includes / media / SVGMetadataExtractorTest.php
blob07ab4c15810490d42351185b3b0af0104f2d34da
1 <?php
3 class SVGMetadataExtractorTest extends MediaWikiTestCase {
5 function setUp() {
6 AutoLoader::loadClass( 'SVGMetadataExtractorTest' );
9 /**
10 * @dataProvider providerSvgFiles
12 function testGetMetadata( $infile, $expected ) {
13 $this->assertMetadata( $infile, $expected );
16 /**
17 * @dataProvider providerSvgFilesWithXMLMetadata
19 function testGetXMLMetadata( $infile, $expected ) {
20 $r = new XMLReader();
21 if( !method_exists( $r, 'readInnerXML()' ) ) {
22 $this->markTestSkipped( 'XMLReader::readInnerXML() does not exist (libxml >2.6.20 needed).' );
23 return;
25 $this->assertMetadata( $infile, $expected );
28 function assertMetadata( $infile, $expected ) {
29 try {
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)' );
35 } else {
36 throw $e;
41 function providerSvgFiles() {
42 $base = dirname( __FILE__ );
43 return array(
44 array(
45 "$base/Wikimedia-logo.svg",
46 array(
47 'width' => 1024,
48 'height' => 1024
51 array(
52 "$base/QA_icon.svg",
53 array(
54 'width' => 60,
55 'height' => 60
58 array(
59 "$base/Gtk-media-play-ltr.svg",
60 array(
61 'width' => 60,
62 'height' => 60
68 function providerSvgFilesWithXMLMetadata() {
69 $base = dirname( __FILE__ );
70 return array(
71 array(
72 "$base/US_states_by_total_state_tax_revenue.svg",
73 array(
74 'height' => 593,
75 'metadata' =>
76 '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
77 <ns4:Work xmlns:ns4="http://creativecommons.org/ns#" rdf:about="">
78 <ns5:format xmlns:ns5="http://purl.org/dc/elements/1.1/">image/svg+xml</ns5:format>
79 <ns5:type xmlns:ns5="http://purl.org/dc/elements/1.1/" rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
80 </ns4:Work>
81 </rdf:RDF>',
82 'width' => 959