mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 12:35:31 +00:00
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
class SimpleXmlUtilTest extends WikiaBaseTest {
|
|
private $simpleXmlUtil;
|
|
|
|
protected function setUp() {
|
|
$this->setupFile = dirname( __FILE__ ) . '/../PortableInfobox.setup.php';
|
|
parent::setUp();
|
|
|
|
$this->simpleXmlUtil = \Wikia\PortableInfobox\Helpers\SimpleXmlUtil::getInstance();
|
|
}
|
|
|
|
protected function tearDown() {
|
|
// we use libxml only for tests here
|
|
libxml_clear_errors();
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider testGetInnerXMLDataProvider
|
|
*/
|
|
public function testGetInnerXML( $xmlString, $expValue, $message ) {
|
|
$xml = simplexml_load_string( $xmlString );
|
|
$this->assertEquals( $expValue, $this->simpleXmlUtil->getInnerXML( $xml ), $message );
|
|
}
|
|
|
|
public function testGetInnerXMLDataProvider() {
|
|
return [
|
|
[
|
|
'<data source="name"><default><gallery orientation="mosaic">TestFile.png</gallery></default></data>',
|
|
'<default><gallery orientation="mosaic">TestFile.png</gallery></default>',
|
|
'Valid gallery tag in default'
|
|
],
|
|
[
|
|
'<data source="name"><default>Test <ref name="multiple" /></default></data>',
|
|
'<default>Test <ref name="multiple"/></default>',
|
|
'Text + XML'
|
|
],
|
|
[
|
|
'<data source="name"><default><ref name="multiple" /></default></data>',
|
|
'<default><ref name="multiple"/></default>',
|
|
'Valid self-closing tag'
|
|
|
|
],
|
|
[
|
|
'<data source="name"><default><ref name="multiple" ></default></data>',
|
|
'',
|
|
'Invalid inner XML'
|
|
],
|
|
[
|
|
'<data source="name"><default></data>',
|
|
'',
|
|
'Invalid inner XML'
|
|
],
|
|
[
|
|
'<data source="name" />',
|
|
'',
|
|
'No inner XML'
|
|
]
|
|
];
|
|
}
|
|
}
|