small testing

This commit is contained in:
Diana 2015-06-22 15:38:47 +00:00
parent 4a183481c3
commit da9648461e
2 changed files with 16 additions and 5 deletions

View file

@ -147,8 +147,9 @@ class Node {
$value = $this->extractDataFromSource( $xmlNode );
if ( !$value && $xmlNode->{self::DEFAULT_TAG_NAME} ) {
$value = $this->extractDataFromNode( $xmlNode->{self::DEFAULT_TAG_NAME} );
} elseif ( $value && $xmlNode->{self::FORMAT_TAG_NAME} ) {
return $this->extractDataFromNode( $xmlNode->{self::DEFAULT_TAG_NAME} );
}
if ( $value && $xmlNode->{self::FORMAT_TAG_NAME} ) {
$value = $this->extractDataFromNode( $xmlNode->{self::FORMAT_TAG_NAME} );
}

View file

@ -31,6 +31,8 @@ class NodeDataTest extends WikiaBaseTest {
[ ], [ 'test1', 'test2' ] ],
[ '<data><default>{{#switch: {{{test2|}}}|{{{test3}}}|{{{test4|kdjk|sajdkfj|}}}]] }}</default></data>',
[ ], [ 'test2', 'test3', 'test4' ] ],
[ '<data><format>my {{{test2}}}$$$</format><default>{{#switch: {{{test2|}}}|{{{test3}}}|{{{test4|kdjk|sajdkfj|}}}]] }}</default></data>',
[ ], [ 'test2', 'test3', 'test4' ] ]
];
}
@ -77,7 +79,13 @@ class NodeDataTest extends WikiaBaseTest {
[ 'value' => 'def', 'label' => 'l' ] ],
[ '<data source="test"><label>l</label><default>def</default></data>', [ 'test' => 1 ],
[ 'value' => 1, 'label' => 'l' ] ],
[ '<data></data>', [ ], [ 'label' => '', 'value' => null ] ]
[ '<data></data>', [ ], [ 'label' => '', 'value' => null ] ],
[ '<data source="test"><label>l</label><format>{{{test}}}%</format><default>def</default></data>', [ 'test' => 1 ],
[ 'value' => '{{{test}}}%', 'label' => 'l' ] ],
[ '<data source="test"><label>l</label><format>{{{not_defined_var}}}%</format><default>def</default></data>', [ 'test' => 1 ],
[ 'value' => '{{{not_defined_var}}}%', 'label' => 'l' ] ],
[ '<data source="test"><label>l</label><format>{{{test}}}%</format><default>def</default></data>', [ ],
[ 'value' => 'def', 'label' => 'l' ] ],
];
}
@ -97,8 +105,10 @@ class NodeDataTest extends WikiaBaseTest {
public function dataRenderProvider() {
return [
[ '<data source="test"></data>', [ 'test' => 'test' ],
[ 'type' => 'data', 'data' => [ 'value' => 'test', 'label' => '' ] ] ],
[ '<data source="test"></data>',
[ 'test' => 'test' ],
[ 'type' => 'data', 'data' => [ 'value' => 'test', 'label' => '' ] ]
]
];
}