From da9648461ef150d9b05f1fd991259e3ac5a6caca Mon Sep 17 00:00:00 2001 From: Diana Date: Mon, 22 Jun 2015 15:38:47 +0000 Subject: [PATCH] small testing --- services/Parser/Nodes/Node.php | 5 +++-- tests/nodes/NodeDataTest.php | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/services/Parser/Nodes/Node.php b/services/Parser/Nodes/Node.php index 5e9b172..902cd4c 100644 --- a/services/Parser/Nodes/Node.php +++ b/services/Parser/Nodes/Node.php @@ -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} ); } diff --git a/tests/nodes/NodeDataTest.php b/tests/nodes/NodeDataTest.php index 2c7a233..5abae64 100644 --- a/tests/nodes/NodeDataTest.php +++ b/tests/nodes/NodeDataTest.php @@ -31,6 +31,8 @@ class NodeDataTest extends WikiaBaseTest { [ ], [ 'test1', 'test2' ] ], [ '{{#switch: {{{test2|}}}|{{{test3}}}|{{{test4|kdjk|sajdkfj|}}}]] }}', [ ], [ 'test2', 'test3', 'test4' ] ], + [ 'my {{{test2}}}$$${{#switch: {{{test2|}}}|{{{test3}}}|{{{test4|kdjk|sajdkfj|}}}]] }}', + [ ], [ 'test2', 'test3', 'test4' ] ] ]; } @@ -77,7 +79,13 @@ class NodeDataTest extends WikiaBaseTest { [ 'value' => 'def', 'label' => 'l' ] ], [ 'def', [ 'test' => 1 ], [ 'value' => 1, 'label' => 'l' ] ], - [ '', [ ], [ 'label' => '', 'value' => null ] ] + [ '', [ ], [ 'label' => '', 'value' => null ] ], + [ '{{{test}}}%def', [ 'test' => 1 ], + [ 'value' => '{{{test}}}%', 'label' => 'l' ] ], + [ '{{{not_defined_var}}}%def', [ 'test' => 1 ], + [ 'value' => '{{{not_defined_var}}}%', 'label' => 'l' ] ], + [ '{{{test}}}%def', [ ], + [ 'value' => 'def', 'label' => 'l' ] ], ]; } @@ -97,8 +105,10 @@ class NodeDataTest extends WikiaBaseTest { public function dataRenderProvider() { return [ - [ '', [ 'test' => 'test' ], - [ 'type' => 'data', 'data' => [ 'value' => 'test', 'label' => '' ] ] ], + [ '', + [ 'test' => 'test' ], + [ 'type' => 'data', 'data' => [ 'value' => 'test', 'label' => '' ] ] + ] ]; }