cvs: pear /DB_NestedSet NestedSet.php /DB_NestedSet/tests/NestedSet query.php

From: Date: Tue, 25 Oct 2005 22:09:43 +0000
Subject: cvs: pear /DB_NestedSet NestedSet.php /DB_NestedSet/tests/NestedSet query.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-35860@lists.php.net to get a copy of this message
datenpunk Tue Oct 25 18:09:43 2005 EDT Modified files: /pear/DB_NestedSet NestedSet.php /pear/DB_NestedSet/tests/NestedSet query.php Log: Fixed Bug #3536 getSiblings doesn't work on root level Expanded the unit tests to catch this bug http://cvs.php.net/diff.php/pear/DB_NestedSet/NestedSet.php?r1=1.86&r2=1.87&ty=u Index: pear/DB_NestedSet/NestedSet.php diff -u pear/DB_NestedSet/NestedSet.php:1.86 pear/DB_NestedSet/NestedSet.php:1.87 --- pear/DB_NestedSet/NestedSet.php:1.86 Tue Aug 10 17:41:28 2004 +++ pear/DB_NestedSet/NestedSet.php Tue Oct 25 18:09:32 2005 @@ -15,7 +15,7 @@ // | Authors: Daniel Khan <dk@webcluster.at> | // | Jason Rust <jason@rustyparts.com> | // +----------------------------------------------------------------------+ -// $Id: NestedSet.php,v 1.86 2004/08/10 21:41:28 datenpunk Exp $ +// $Id: NestedSet.php,v 1.87 2005/10/25 22:09:32 datenpunk Exp $ // CREDITS: // -------- // - Thanks to Kristian Koehntopp for publishing an explanation of the Nested Set @@ -50,7 +50,7 @@ * * @author Daniel Khan <dk@webcluster.at> * @package DB_NestedSet -* @version $Revision: 1.86 $ +* @version $Revision: 1.87 $ * @access public */ // }}} @@ -659,6 +659,10 @@ return $this->_raiseError(NESE_ERROR_NOT_FOUND, PEAR_ERROR_TRIGGER, E_USER_NOTICE, $epr); } + if($sibling['id'] == $sibling['rootid']) { + return $this->getRootNodes($keepAsArray, $aliasFields, $addSQL); + } + $parent = $this->getParent($sibling, true); return $this->getChildren($parent, $keepAsArray, $aliasFields, false, $addSQL); } @@ -1844,17 +1848,17 @@ * @access private */ function _secSort($nodeSet) { - + // Nothing to do - empty tree if(empty($nodeSet)) { return $nodeSet; } - + $retArray = array(); foreach($nodeSet AS $nodeID=>$node) { $deepArray[$node['parent']][$nodeID] = $node; } - + $reset = true; foreach($deepArray AS $parentID=>$children) { $retArray = $this->_secSortCollect($children, $deepArray, $reset); @@ -2086,7 +2090,7 @@ 'majorversion' => $this->_majorversion, 'minorversion' => $this->_minorversion, 'version' => sprintf('%s.%s', $this->_majorversion, $this->_minorversion), - 'revision' => str_replace('$', '', '$Revision: 1.86 $') + 'revision' => str_replace('$', '', '$Revision: 1.87 $') ); } // }}} @@ -2470,7 +2474,7 @@ * Generic class for node objects * * @autor Daniel Khan <dk@webcluster.at>; -* @version $Revision: 1.86 $ +* @version $Revision: 1.87 $ * @package DB_NestedSet * @access private */ http://cvs.php.net/diff.php/pear/DB_NestedSet/tests/NestedSet/query.php?r1=1.6&r2=1.7&ty=u Index: pear/DB_NestedSet/tests/NestedSet/query.php diff -u pear/DB_NestedSet/tests/NestedSet/query.php:1.6 pear/DB_NestedSet/tests/NestedSet/query.php:1.7 --- pear/DB_NestedSet/tests/NestedSet/query.php:1.6 Tue Oct 25 17:32:06 2005 +++ pear/DB_NestedSet/tests/NestedSet/query.php Tue Oct 25 18:09:41 2005 @@ -5,7 +5,7 @@ * * @author Daniel Khan <dk@webcluster.at> * @package DB_NestedSetTest - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @access public */ @@ -71,6 +71,8 @@ return true; } + + /** * tests_NestedSet_common::test_getParents() * @@ -144,6 +146,13 @@ $this->assertEquals($children, $siblings, 'Children don\'t match getSiblings()'); } } + + $rootnodes = $this->_NeSe->getRootNodes(true, true, $this->addSQL); + $rootnode = current($rootnodes); + $siblings_of_rootnode = $this->_NeSe->getSiblings($rootnode['id'], true, true, $this->addSQL); + + $this->assertEquals($rootnodes, $siblings_of_rootnode, 'Siblings of a rootnode should be all rootnodes'); + return true; }

« previous php.pear.cvs (#35860) next »