@@ -73,6 +73,33 @@ public function it_strips_children_that_are_not_in_the_given_path_with_several_n
7373 $ this ->nodeOnlyHasChild ($ node1 , 'node_1_b ' );
7474 }
7575
76+ /**
77+ * @test
78+ */
79+ public function it_strips_children_when_leaf_node_is_not_an_array ()
80+ {
81+ $ treeBuilder = new TreeBuilder ();
82+ $ root = $ treeBuilder ->root ('root ' );
83+ $ root
84+ ->children ()
85+ ->arrayNode ('node_1 ' )
86+ ->children ()
87+ ->scalarNode ('node_1_scalar_node ' )
88+ ->end ()
89+ ->end ()
90+ ->end ()
91+ ->scalarNode ('node_2 ' )
92+ ->end ()
93+ ->scalarNode ('node_3 ' );
94+
95+ $ node = $ treeBuilder ->buildTree ();
96+ /** @var ArrayNode $node */
97+
98+ PartialNode::excludeEverythingNotInPath ($ node , array ('node_3 ' ));
99+
100+ $ this ->nodeOnlyHasChild ($ node , 'node_3 ' );
101+ }
102+
76103 /**
77104 * @test
78105 */
@@ -98,7 +125,7 @@ public function it_fails_when_a_requested_child_node_does_not_exist()
98125 /**
99126 * @test
100127 */
101- public function it_fails_when_a_requested_child_node_is_no_array_node_itself ()
128+ public function it_fails_when_a_requested_child_node_is_no_array_node_itself_and_path_not_empty ()
102129 {
103130 $ treeBuilder = new TreeBuilder ();
104131 $ root = $ treeBuilder ->root ('root ' );
@@ -114,7 +141,7 @@ public function it_fails_when_a_requested_child_node_is_no_array_node_itself()
114141 'Matthias\SymfonyConfigTest\Partial\Exception\ChildIsNotAnArrayNode ' ,
115142 'Child node "scalar_node" is not an array node (current path: "root.sub_node") '
116143 );
117- PartialNode::excludeEverythingNotInPath ($ node , array ('sub_node ' , 'scalar_node ' ));
144+ PartialNode::excludeEverythingNotInPath ($ node , array ('sub_node ' , 'scalar_node ' , ' extra_node ' ));
118145 }
119146
120147 private function nodeOnlyHasChild (ArrayNode $ node , $ nodeName )
0 commit comments