mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-23 15:57:10 +00:00
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
use PortableInfobox\Parser\XmlParser;
|
|
|
|
/**
|
|
* @group PortableInfobox
|
|
* @covers \PortableInfobox\Parser\XmlParser
|
|
*/
|
|
class XmlParserTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/** @dataProvider contentTagsDataProvider */
|
|
public function testXHTMLParsing( $tag, $content ) {
|
|
$markup = "<data source=\"asdfd\"><{$tag}>{$content}</{$tag}></data>";
|
|
$result = 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 = 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>', '&' ]
|
|
];
|
|
}
|
|
}
|