Skip to content

Command node:list (ls): Fix wrong node counter #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions features/all/phpcr_node_list.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: List properites and chidren of current nodeA
Feature: List properties and children of current nodeA
In order to list the properties and children of the current node
As a user that is logged into the shell
I should be able to run a command which does that
Expand Down Expand Up @@ -136,7 +136,23 @@ Feature: List properites and chidren of current nodeA
+---------------------+---------+--------------+
"""

Scenario: Correct node count
Scenario: Correct node count (simple)
Given I execute the "node:list /tests_general_base" command
Then the command should not fail
And I should see the following:
"""
9 nodes, 1 properties in set
"""

Scenario: Correct node count (recursive without properties)
Given I execute the "node:list --children --level=1 /tests_general_base" command
Then the command should not fail
And I should see the following:
"""
16 nodes, 0 properties in set
"""

Scenario: Correct node count (wildcard)
Given I execute the "node:list /tests_general_base/*/jcr:content" command
Then the command should not fail
And I should see the following:
Expand Down
3 changes: 1 addition & 2 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->renderNode($node, $table, [], $filter);

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

$i = 0;
foreach ($children as $child) {
$this->nbNodes++;
$i++;
if (isset($childNodeNames[$child->getName()])) {
unset($childNodeNames[$child->getName()]);
Expand Down Expand Up @@ -204,7 +204,6 @@ private function renderChildren($currentNode, $table, $spacers, $filter = null)
$newSpacers[] = '| ';
}

$this->nbNodes++;
$this->renderNode($child, $table, $newSpacers);
}
}
Expand Down