mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-30 19:15:24 +00:00
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* @group PortableInfobox
|
|
* @covers PortableInfobox\Parser\XmlParser
|
|
*/
|
|
class XmlParserTest extends MediaWikiTestCase {
|
|
|
|
/** @dataProvider contentTagsDataProvider */
|
|
public function testXHTMLParsing( $tag, $content ) {
|
|
$markup = "<data source=\"asdfd\"><{$tag}>{$content}</{$tag}></data>";
|
|
$result = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
|
|
|
$this->assertEquals( $content, (string)$result->{$tag} );
|
|
}
|
|
|
|
public function contentTagsDataProvider() {
|
|
return [
|
|
[ 'default', 'sadf <br> sakdjfl' ],
|
|
[ 'format', '<>' ],
|
|
[ 'label', '' ]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider entitiesTestDataProvider
|
|
*/
|
|
public function testHTMLEntities( $markup, $expectedResult ) {
|
|
$result = PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
|
|
$this->assertEquals( $expectedResult, $result[ 0 ] );
|
|
}
|
|
|
|
public function entitiesTestDataProvider() {
|
|
return [
|
|
[ '<data></data>', '' ],
|
|
[ '<data>&aksjdf;</data>', '&aksjdf;' ],
|
|
[ '<data>&</data>', '&' ],
|
|
[ '<data>·</data>', '·' ],
|
|
[ '<data>Ü</data>', 'Ü' ],
|
|
[ '<data>Δ</data>', 'Δ' ],
|
|
[ '<data>&amp;</data>', '&' ],
|
|
[ '<data>&</data>', '&' ]
|
|
];
|
|
}
|
|
}
|