mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
71 lines
1.3 KiB
PHP
71 lines
1.3 KiB
PHP
<?php
|
|
|
|
class NodeTest extends WikiaBaseTest {
|
|
|
|
protected function setUp() {
|
|
$this->setupFile = dirname( __FILE__ ) . '/../PortableInfobox.setup.php';
|
|
parent::setUp();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider testIsEmptyDataProvider
|
|
*/
|
|
public function testIsEmpty( $season, $expectedOutput ) {
|
|
$string = '<data source="season"><label>Season</label></data>';
|
|
$xml = simplexml_load_string( $string );
|
|
|
|
$node = new Wikia\PortableInfobox\Parser\Nodes\NodeData( $xml, [ 'season' => $season ] );
|
|
$nodeData = $node->getData();
|
|
$this->assertTrue( $node->isEmpty( $nodeData ) == $expectedOutput );
|
|
}
|
|
|
|
public function testIsEmptyDataProvider() {
|
|
return [
|
|
[
|
|
'season' => '0',
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => '1',
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => 'one',
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => 'null',
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => 'false',
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => ' ',
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => null,
|
|
'expectedOutput' => true
|
|
],
|
|
[
|
|
'season' => [],
|
|
'expectedOutput' => true
|
|
],
|
|
[
|
|
'season' => '',
|
|
'expectedOutput' => true
|
|
],
|
|
[
|
|
'season' => 5,
|
|
'expectedOutput' => false
|
|
],
|
|
[
|
|
'season' => 0,
|
|
'expectedOutput' => false
|
|
]
|
|
];
|
|
}
|
|
}
|