mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 04:22:37 +00:00
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
class XmlParserTest extends WikiaBaseTest {
|
|
|
|
protected function setUp() {
|
|
$this->setupFile = dirname( __FILE__ ) . '/../PortableInfobox.setup.php';
|
|
parent::setUp();
|
|
}
|
|
|
|
public function testIsEmpty() {
|
|
$parser = new \Wikia\PortableInfobox\Parser\XmlParser([
|
|
'elem2' => 'ELEM2',
|
|
'lado2' => 'LALALA',
|
|
'nonempty' => '111'
|
|
]);
|
|
$markup = '
|
|
<infobox>
|
|
<comparison>
|
|
<set>
|
|
<header>Combatientes</header>
|
|
<data source="lado1" />
|
|
<data source="lado2" />
|
|
</set>
|
|
</comparison>
|
|
<data source="empty" />
|
|
<data source="nonempty"><label>nonemepty</label></data>
|
|
</infobox>
|
|
';
|
|
$data = $parser->getDataFromXmlString( $markup );
|
|
$this->assertTrue( $data[0]['data']['value'][0]['data']['value'][0]['data']['value'] == 'Combatientes' );
|
|
$this->assertTrue( $data[1]['data']['value'] == '111' );
|
|
}
|
|
|
|
public function testExternalParser() {
|
|
$parser = new \Wikia\PortableInfobox\Parser\XmlParser([
|
|
'elem2' => 'ELEM2',
|
|
'lado2' => 'LALALA'
|
|
]);
|
|
$externalParser = new \Wikia\PortableInfobox\Parser\DummyParser();
|
|
$parser->setExternalParser( $externalParser );
|
|
$markup = '
|
|
<infobox>
|
|
<title><default>ABB</default></title>
|
|
<comparison>
|
|
<set>
|
|
<header>Combatientes</header>
|
|
<data source="lado1" />
|
|
<data source="lado2" />
|
|
</set>
|
|
</comparison>
|
|
<footer>[[aaa]]</footer>
|
|
</infobox>
|
|
';
|
|
$data = $parser->getDataFromXmlString( $markup );
|
|
$this->assertTrue( $data[0]['data']['value'] == 'parseRecursive(ABB)' );
|
|
$this->assertTrue( $data[1]['data']['value'][0]['data']['value'][1]['data']['value'] == 'parseRecursive(LALALA)');
|
|
}
|
|
}
|