mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 03:35:53 +00:00
footer
This commit is contained in:
parent
87d1005f1b
commit
99ca2eb705
|
@ -2,16 +2,15 @@
|
||||||
namespace Wikia\PortableInfobox\Parser\Nodes;
|
namespace Wikia\PortableInfobox\Parser\Nodes;
|
||||||
|
|
||||||
class NodeFooter extends Node {
|
class NodeFooter extends Node {
|
||||||
const LINKS_TAG_NAME = 'links';
|
|
||||||
|
|
||||||
public function getData() {
|
public function getData() {
|
||||||
$data = [];
|
$data = [];
|
||||||
$data['links'] = $this->parseWithExternalParser( (string) $this->xmlNode->{self::LINKS_TAG_NAME}, true );
|
$data['value'] = $this->parseWithExternalParser( (string) $this->xmlNode, true );
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isEmpty( $data ) {
|
public function isEmpty( $data ) {
|
||||||
$links = trim( $data['links'] );
|
$links = trim( $data['value'] );
|
||||||
return empty( $links );
|
return empty( $links );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<footer class="portable-infobox-footer portable-infobox-item-margins portable-infobox-header-background
|
<footer class="portable-infobox-footer portable-infobox-item-margins portable-infobox-header-background
|
||||||
portable-infobox-header-font">
|
portable-infobox-header-font">
|
||||||
{{{links}}}
|
{{{value}}}
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -52,11 +52,11 @@ class PortableInfoboxParserNodesTest extends WikiaBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNodeFooter() {
|
public function testNodeFooter() {
|
||||||
$string = '<footer><links>123</links></footer>';
|
$string = '<footer>123</footer>';
|
||||||
$xml = simplexml_load_string( $string );
|
$xml = simplexml_load_string( $string );
|
||||||
|
|
||||||
$node = new Wikia\PortableInfobox\Parser\Nodes\NodeFooter( $xml, [ ] );
|
$node = new Wikia\PortableInfobox\Parser\Nodes\NodeFooter( $xml, [ ] );
|
||||||
$this->assertTrue( $node->getData()[ 'links' ] == '123' );
|
$this->assertTrue( $node->getData()[ 'value' ] == '123' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNodeGroup() {
|
public function testNodeGroup() {
|
||||||
|
|
|
@ -28,7 +28,13 @@ class PortableInfoboxRenderServiceTest extends PHPUnit_Framework_TestCase {
|
||||||
$actualDOM->loadXML($actualOutput);
|
$actualDOM->loadXML($actualOutput);
|
||||||
$expectedDOM->loadXML($expectedOutput);
|
$expectedDOM->loadXML($expectedOutput);
|
||||||
|
|
||||||
$this->assertEquals( $expectedDOM->saveXML(), $actualDOM->saveXML(), $description );
|
// lets sanitize expected and actual HTML to not deal with whitespaces
|
||||||
|
$from = ['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', '/> </s'];
|
||||||
|
$to = ['>', '<', '\\1', '><'];
|
||||||
|
$expectedHtml = preg_replace($from, $to, $expectedDOM->saveXML());
|
||||||
|
$actualHtml = preg_replace($from, $to, $actualDOM->saveXML());
|
||||||
|
|
||||||
|
$this->assertEquals( $expectedHtml, $actualHtml, $description );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRenderInfoboxDataProvider() {
|
public function testRenderInfoboxDataProvider() {
|
||||||
|
@ -51,6 +57,19 @@ class PortableInfoboxRenderServiceTest extends PHPUnit_Framework_TestCase {
|
||||||
'output' => '<aside class="portable-infobox"><div class="portable-infobox-item item-type-title portable-infobox-item-margins"><h2 class="portable-infobox-title">Test Title</h2></div></aside>',
|
'output' => '<aside class="portable-infobox"><div class="portable-infobox-item item-type-title portable-infobox-item-margins"><h2 class="portable-infobox-title">Test Title</h2></div></aside>',
|
||||||
'description' => 'Only title'
|
'description' => 'Only title'
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'input' => [
|
||||||
|
[
|
||||||
|
'type' => 'footer',
|
||||||
|
'data' => [
|
||||||
|
'value' => 'Footer value',
|
||||||
|
'isEmpty' => false
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'output' => '<aside class="portable-infobox"><footer class="portable-infobox-footer portable-infobox-item-margins portable-infobox-header-background portable-infobox-header-font">Footer value</footer></aside>',
|
||||||
|
'description' => 'Footer only'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'input' => [
|
'input' => [
|
||||||
[
|
[
|
||||||
|
|
|
@ -27,7 +27,7 @@ class XmlParserTest extends WikiaBaseTest {
|
||||||
<infobox>
|
<infobox>
|
||||||
<comparison>
|
<comparison>
|
||||||
<set>
|
<set>
|
||||||
<header><value>Combatientes</value></header>
|
<header>Combatientes</header>
|
||||||
<data source="lado1" />
|
<data source="lado1" />
|
||||||
<data source="lado2" />
|
<data source="lado2" />
|
||||||
</set>
|
</set>
|
||||||
|
@ -59,14 +59,12 @@ class XmlParserTest extends WikiaBaseTest {
|
||||||
<title><default>ABB</default></title>
|
<title><default>ABB</default></title>
|
||||||
<comparison>
|
<comparison>
|
||||||
<set>
|
<set>
|
||||||
<header><value>Combatientes</value></header>
|
<header>Combatientes</header>
|
||||||
<data source="lado1" />
|
<data source="lado1" />
|
||||||
<data source="lado2" />
|
<data source="lado2" />
|
||||||
</set>
|
</set>
|
||||||
</comparison>
|
</comparison>
|
||||||
<footer>
|
<footer>[[aaa]]</footer>
|
||||||
<links>[[aaa]]</links>
|
|
||||||
</footer>
|
|
||||||
</infobox>
|
</infobox>
|
||||||
';
|
';
|
||||||
$data = $parser->getDataFromXmlString( $markup );
|
$data = $parser->getDataFromXmlString( $markup );
|
||||||
|
|
Loading…
Reference in a new issue