treat 0 as valid value inside <format> tag

This commit is contained in:
Rafal Leszczynski 2015-09-08 11:29:49 +02:00
parent 3e2f331eb2
commit bb7421acb7
2 changed files with 3 additions and 1 deletions

View file

@ -148,7 +148,7 @@ class Node {
if ( !$value && $xmlNode->{self::DEFAULT_TAG_NAME} ) {
return $this->getInnerValue( $xmlNode->{self::DEFAULT_TAG_NAME} );
}
if ( $value && $xmlNode->{self::FORMAT_TAG_NAME} ) {
if ( ( $value || $value == '0' ) && $xmlNode->{self::FORMAT_TAG_NAME} ) {
return $this->getInnerValue( $xmlNode->{self::FORMAT_TAG_NAME} );
}

View file

@ -92,6 +92,8 @@ class NodeDataTest extends WikiaBaseTest {
[ 'value' => '{{{not_defined_var}}}%', 'label' => 'l' ] ],
[ '<data source="test"><label>l</label><format>{{{test}}}%</format><default>def</default></data>', [ ],
[ 'value' => 'def', 'label' => 'l' ] ],
[ '<data source="test"><format>{{{test}}}%</format></data>', [ 'test' => 0 ],
[ 'value' => '{{{test}}}%', 'label' => '' ] ],
];
}