Skip to content

Commit bc9b29f

Browse files
authored
Merge pull request #188 from middlebrain/ls_wrong_node_count_fix
Command node:list (ls): Fix wrong node counter
2 parents a1854c4 + 0598a4d commit bc9b29f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

features/all/phpcr_node_list.feature

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Feature: List properites and chidren of current nodeA
1+
Feature: List properties and children of current nodeA
22
In order to list the properties and children of the current node
33
As a user that is logged into the shell
44
I should be able to run a command which does that
@@ -136,7 +136,23 @@ Feature: List properites and chidren of current nodeA
136136
+---------------------+---------+--------------+
137137
"""
138138

139-
Scenario: Correct node count
139+
Scenario: Correct node count (simple)
140+
Given I execute the "node:list /tests_general_base" command
141+
Then the command should not fail
142+
And I should see the following:
143+
"""
144+
9 nodes, 1 properties in set
145+
"""
146+
147+
Scenario: Correct node count (recursive without properties)
148+
Given I execute the "node:list --children --level=1 /tests_general_base" command
149+
Then the command should not fail
150+
And I should see the following:
151+
"""
152+
16 nodes, 0 properties in set
153+
"""
154+
155+
Scenario: Correct node count (wildcard)
140156
Given I execute the "node:list /tests_general_base/*/jcr:content" command
141157
Then the command should not fail
142158
And I should see the following:

src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public function execute(InputInterface $input, OutputInterface $output)
124124
$this->renderNode($node, $table, [], $filter);
125125

126126
if ($table->getNumberOfRows() > 0) {
127-
$this->nbNodes++;
128127
$output->writeln(sprintf('<pathbold>%s</pathbold> [%s] > %s',
129128
$node->getPath(),
130129
$node->getPrimaryNodeType()->getName(),
@@ -170,6 +169,7 @@ private function renderChildren($currentNode, $table, $spacers, $filter = null)
170169

171170
$i = 0;
172171
foreach ($children as $child) {
172+
$this->nbNodes++;
173173
$i++;
174174
if (isset($childNodeNames[$child->getName()])) {
175175
unset($childNodeNames[$child->getName()]);
@@ -204,7 +204,6 @@ private function renderChildren($currentNode, $table, $spacers, $filter = null)
204204
$newSpacers[] = '| ';
205205
}
206206

207-
$this->nbNodes++;
208207
$this->renderNode($child, $table, $newSpacers);
209208
}
210209
}

0 commit comments

Comments
 (0)