assertEquals( $expected, $node->getData() );
}
public function dataProvider() {
return [
[
'',
[ 'value' => '', 'item-name' => null ]
],
[
'kjdflkja dafkjlsdkfj',
[ 'value' => 'kjdflkja dafkjlsdkfj', 'item-name' => null ]
],
[
'kjdflkja[dafkjlsdkfj]',
[ 'value' => 'kjdflkja[dafkjlsdkfj]', 'item-name' => null ]
],
[
'kjdflkja dafkjlsdkfj',
[ 'value' => 'kjdflkja dafkjlsdkfj', 'item-name' => 'ihatetests' ]
]
];
}
/**
* @dataProvider isEmptyDataProvider
*/
public function testIsEmpty( $string, $expectedOutput ) {
$xml = simplexml_load_string( $string );
$node = new NodeNavigation( $xml, [] );
$data = $node->getData();
$this->assertTrue( $node->isEmpty( $data ) == $expectedOutput );
}
public function isEmptyDataProvider() {
return [
[
'string' => 'goodnight',
'expectedOutput' => false
],
[
'string' => 'null',
'expectedOutput' => false
],
[
'string' => '0',
'expectedOutput' => false
],
[
'string' => '\'0\'',
'expectedOutput' => false
],
[
'string' => '',
'expectedOutput' => true
],
[
'string' => ' ',
'expectedOutput' => true
]
];
}
}