2015-05-20 14:38:23 +00:00
|
|
|
<?php
|
2015-06-11 12:51:54 +00:00
|
|
|
|
2015-05-20 14:38:23 +00:00
|
|
|
class NodeFooterTest extends WikiaBaseTest {
|
|
|
|
protected function setUp() {
|
2015-06-11 12:51:54 +00:00
|
|
|
$this->setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php';
|
2015-05-20 14:38:23 +00:00
|
|
|
parent::setUp();
|
|
|
|
}
|
2015-06-11 12:51:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers NodeFooter::getData
|
|
|
|
* @covers Node::getInnerValue
|
|
|
|
* @dataProvider dataProvider
|
|
|
|
*
|
|
|
|
* @param $markup
|
|
|
|
* @param $params
|
|
|
|
* @param $expected
|
|
|
|
*/
|
|
|
|
public function testData( $markup, $params, $expected ) {
|
|
|
|
$node = \Wikia\PortableInfobox\Parser\Nodes\NodeFactory::newFromXML( $markup, $params );
|
|
|
|
|
|
|
|
$this->assertEquals( $expected, $node->getData() );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataProvider() {
|
|
|
|
return [
|
|
|
|
[ '<footer></footer>', [ ], [ 'value' => '' ] ],
|
|
|
|
[ '<footer>kjdflkja dafkjlsdkfj</footer>', [ ], [ 'value' => 'kjdflkja dafkjlsdkfj' ] ],
|
|
|
|
[ '<footer>kjdflkja<ref>dafkjlsdkfj</ref></footer>', [ ], [ 'value' => 'kjdflkja<ref>dafkjlsdkfj</ref>' ] ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-05-20 14:38:23 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider testIsEmptyDataProvider
|
|
|
|
*/
|
|
|
|
public function testIsEmpty( $string, $expectedOutput ) {
|
|
|
|
$xml = simplexml_load_string( $string );
|
2015-06-11 12:51:54 +00:00
|
|
|
$node = new Wikia\PortableInfobox\Parser\Nodes\NodeFooter( $xml, [ ] );
|
2015-05-20 14:38:23 +00:00
|
|
|
$data = $node->getData();
|
|
|
|
$this->assertTrue( $node->isEmpty( $data ) == $expectedOutput );
|
|
|
|
}
|
2015-06-11 12:51:54 +00:00
|
|
|
|
2015-05-20 14:38:23 +00:00
|
|
|
public function testIsEmptyDataProvider() {
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'string' => '<footer>goodnight</footer>',
|
|
|
|
'expectedOutput' => false
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'string' => '<footer>null</footer>',
|
|
|
|
'expectedOutput' => false
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'string' => '<footer>0</footer>',
|
2015-05-20 14:57:43 +00:00
|
|
|
'expectedOutput' => false
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'string' => '<footer>\'0\'</footer>',
|
|
|
|
'expectedOutput' => false
|
2015-05-20 14:38:23 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'string' => '<footer></footer>',
|
|
|
|
'expectedOutput' => true
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'string' => '<footer> </footer>',
|
|
|
|
'expectedOutput' => true
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|