setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php';
parent::setUp();
}
/**
* @covers \Wikia\PortableInfobox\Parser\Nodes\NodeNavigation::getData
* @covers \Wikia\PortableInfobox\Parser\Nodes\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 [
[ '', [ ], [ 'value' => '' ] ],
[ 'kjdflkja dafkjlsdkfj', [ ], [ 'value' => 'kjdflkja dafkjlsdkfj' ] ],
[ 'kjdflkja[dafkjlsdkfj]', [ ], [ 'value' => 'kjdflkja[dafkjlsdkfj]' ] ],
];
}
/**
* @dataProvider testIsEmptyDataProvider
*/
public function testIsEmpty( $string, $expectedOutput ) {
$xml = simplexml_load_string( $string );
$node = new Wikia\PortableInfobox\Parser\Nodes\NodeNavigation( $xml, [ ] );
$data = $node->getData();
$this->assertTrue( $node->isEmpty( $data ) == $expectedOutput );
}
public function testIsEmptyDataProvider() {
return [
[
'string' => 'goodnight',
'expectedOutput' => false
],
[
'string' => 'null',
'expectedOutput' => false
],
[
'string' => '0',
'expectedOutput' => false
],
[
'string' => '\'0\'',
'expectedOutput' => false
],
[
'string' => '',
'expectedOutput' => true
],
[
'string' => ' ',
'expectedOutput' => true
]
];
}
}