1
0
mirror of synced 2024-12-13 14:56:01 +03:00

Fixed Doctrine_Node_NestedSet::getNumberChildren()

This commit is contained in:
romanb 2007-08-20 07:45:29 +00:00
parent 6d4f7da224
commit ce90ee576a
2 changed files with 8 additions and 6 deletions

View File

@ -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;
} }
/** /**

View File

@ -72,6 +72,13 @@ class Doctrine_NestedSet_SingleRoot_TestCase extends Doctrine_UnitTestCase
$this->assertEqual('node2', $desc[0]['name']); $this->assertEqual('node2', $desc[0]['name']);
$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()
{ {