2015-04-27 14:05:31 +00:00
|
|
|
<?php
|
2018-08-08 09:42:22 +00:00
|
|
|
/**
|
|
|
|
* @group PortableInfobox
|
2018-08-09 09:49:10 +00:00
|
|
|
* @covers PortableInfobox\Parser\XmlParser
|
2018-08-08 09:42:22 +00:00
|
|
|
*/
|
2021-12-15 22:01:13 +00:00
|
|
|
class XmlParserTest extends MediaWikiIntegrationTestCase {
|
2015-04-27 14:05:31 +00:00
|
|
|
|
2015-09-07 10:22:56 +00:00
|
|
|
/** @dataProvider contentTagsDataProvider */
|
|
|
|
public function testXHTMLParsing( $tag, $content ) {
|
|
|
|
$markup = "<data source=\"asdfd\"><{$tag}>{$content}</{$tag}></data>";
|
2018-08-09 09:49:10 +00:00
|
|
|
$result = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
2015-05-20 10:15:22 +00:00
|
|
|
|
2015-09-07 10:22:56 +00:00
|
|
|
$this->assertEquals( $content, (string)$result->{$tag} );
|
|
|
|
}
|
2015-05-19 14:01:53 +00:00
|
|
|
|
2015-09-07 10:22:56 +00:00
|
|
|
public function contentTagsDataProvider() {
|
|
|
|
return [
|
|
|
|
[ 'default', 'sadf <br> sakdjfl' ],
|
|
|
|
[ 'format', '<>' ],
|
|
|
|
[ 'label', '' ]
|
|
|
|
];
|
2015-05-19 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2015-07-06 16:15:29 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider entitiesTestDataProvider
|
|
|
|
*/
|
|
|
|
public function testHTMLEntities( $markup, $expectedResult ) {
|
2018-08-09 09:49:10 +00:00
|
|
|
$result = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
2021-09-11 23:07:07 +00:00
|
|
|
$this->assertEquals( $expectedResult, $result[ 0 ] );
|
2015-07-06 16:15:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function entitiesTestDataProvider() {
|
|
|
|
return [
|
|
|
|
[ '<data></data>', '' ],
|
|
|
|
[ '<data>&aksjdf;</data>', '&aksjdf;' ],
|
|
|
|
[ '<data>&</data>', '&' ],
|
2015-07-07 07:06:37 +00:00
|
|
|
[ '<data>·</data>', '·' ],
|
|
|
|
[ '<data>Ü</data>', 'Ü' ],
|
|
|
|
[ '<data>Δ</data>', 'Δ' ],
|
|
|
|
[ '<data>&amp;</data>', '&' ],
|
|
|
|
[ '<data>&</data>', '&' ]
|
2015-07-06 16:15:29 +00:00
|
|
|
];
|
|
|
|
}
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|