mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
Merge pull request #7282 from Wikia/DAT-2829
DAT-2829 Don't treat '0' as an empty value in footer
This commit is contained in:
commit
3625507785
|
@ -11,6 +11,6 @@ class NodeFooter extends Node {
|
|||
|
||||
public function isEmpty( $data ) {
|
||||
$links = trim( $data['value'] );
|
||||
return empty( $links );
|
||||
return empty( $links ) && $links != '0';
|
||||
}
|
||||
}
|
||||
|
|
44
tests/NodeFooterTest.php
Normal file
44
tests/NodeFooterTest.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
class NodeFooterTest extends WikiaBaseTest {
|
||||
protected function setUp() {
|
||||
$this->setupFile = dirname( __FILE__ ) . '/../PortableInfobox.setup.php';
|
||||
parent::setUp();
|
||||
}
|
||||
/**
|
||||
* @dataProvider testIsEmptyDataProvider
|
||||
*/
|
||||
public function testIsEmpty( $string, $expectedOutput ) {
|
||||
$xml = simplexml_load_string( $string );
|
||||
$node = new Wikia\PortableInfobox\Parser\Nodes\NodeFooter( $xml, [] );
|
||||
$data = $node->getData();
|
||||
$this->assertTrue( $node->isEmpty( $data ) == $expectedOutput );
|
||||
}
|
||||
public function testIsEmptyDataProvider() {
|
||||
return [
|
||||
[
|
||||
'string' => '<footer>goodnight</footer>',
|
||||
'expectedOutput' => false
|
||||
],
|
||||
[
|
||||
'string' => '<footer>null</footer>',
|
||||
'expectedOutput' => false
|
||||
],
|
||||
[
|
||||
'string' => '<footer>0</footer>',
|
||||
'expectedOutput' => false
|
||||
],
|
||||
[
|
||||
'string' => '<footer>\'0\'</footer>',
|
||||
'expectedOutput' => false
|
||||
],
|
||||
[
|
||||
'string' => '<footer></footer>',
|
||||
'expectedOutput' => true
|
||||
],
|
||||
[
|
||||
'string' => '<footer> </footer>',
|
||||
'expectedOutput' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue