Commit ce90ee57 authored by romanb's avatar romanb

Fixed Doctrine_Node_NestedSet::getNumberChildren()

parent 6d4f7da2
...@@ -318,12 +318,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -318,12 +318,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
*/ */
public function getNumberChildren() public function getNumberChildren()
{ {
$count = 0; return count($this->getChildren());
$children = $this->getChildren();
while ($children->next()) {
$count++;
}
return $count;
} }
/** /**
......
...@@ -73,6 +73,13 @@ class Doctrine_NestedSet_SingleRoot_TestCase extends Doctrine_UnitTestCase ...@@ -73,6 +73,13 @@ class Doctrine_NestedSet_SingleRoot_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(1, $desc[0]['level']); $this->assertEqual(1, $desc[0]['level']);
} }
public function testGetNumberChildren()
{
$treeMngr = $this->conn->getTable('NestedSetTest_SingleRootNode')->getTree();
$root = $treeMngr->fetchRoot();
$this->assertEqual(1, $root->getNode()->getNumberChildren());
}
public function testGetAncestors() public function testGetAncestors()
{ {
$node = $this->conn->query("SELECT n.* FROM NestedSetTest_SingleRootNode n WHERE n.name = ?", $node = $this->conn->query("SELECT n.* FROM NestedSetTest_SingleRootNode n WHERE n.name = ?",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment