cvs: pear /DB_NestedSet/tests UnitTest.php /DB_NestedSet/tests/NestedSet creation.php

From: Date: Sat, 27 Sep 2003 21:51:56 +0000
Subject: cvs: pear /DB_NestedSet/tests UnitTest.php /DB_NestedSet/tests/NestedSet creation.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13142@lists.php.net to get a copy of this message
datenpunk Sat Sep 27 17:51:56 2003 EDT Modified files: /pear/DB_NestedSet/tests UnitTest.php /pear/DB_NestedSet/tests/NestedSet creation.php Log: Moving on doing unit test cases Index: pear/DB_NestedSet/tests/UnitTest.php diff -u pear/DB_NestedSet/tests/UnitTest.php:1.6 pear/DB_NestedSet/tests/UnitTest.php:1.7 --- pear/DB_NestedSet/tests/UnitTest.php:1.6 Thu Sep 25 09:50:03 2003 +++ pear/DB_NestedSet/tests/UnitTest.php Sat Sep 27 17:51:55 2003 @@ -5,7 +5,7 @@ * * @author Daniel Khan <dk@webcluster.at> * @package DB_NestedSetTest -* @version $Revision: 1.6 $ +* @version $Revision: 1.7 $ * @access public */ class DB_NestedSetTest extends TestBase { Index: pear/DB_NestedSet/tests/NestedSet/creation.php diff -u pear/DB_NestedSet/tests/NestedSet/creation.php:1.1 pear/DB_NestedSet/tests/NestedSet/creation.php:1.2 --- pear/DB_NestedSet/tests/NestedSet/creation.php:1.1 Thu Sep 25 09:50:04 2003 +++ pear/DB_NestedSet/tests/NestedSet/creation.php Sat Sep 27 17:51:55 2003 @@ -5,7 +5,7 @@ * * @author Daniel Khan <dk@webcluster.at> * @package DB_NestedSetTest -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ @@ -87,7 +87,7 @@ $values['STRNA'] = 'RSR'.$x; // Try to overwrite the ROOTID which should be set inside the method - //$values['ROOTID'] = -100; + // $values['ROOTID'] = -100; $rn2 = $this->_NeSe->createRightNode($sid, $values); $x++; @@ -127,6 +127,67 @@ $this->assertEquals($rnc*4, count($allnodes), "Wrong node count after right insertion"); return true; } + + /** + * tests_NestedSet_common::test_createLeftNode() + * + * Create some left nodes and query some meta informations + * + * @access public + * @see _createSubNode() + * @return bool True on completion + */ + function test_createLeftNode() { + $rnc = 6; + $rootnodes = $this->_createRootNodes($rnc); + $x = 0; + foreach($rootnodes AS $rid=>$rootnode) { + $values['STRNA'] = 'R'.$x; + $rn1 = $this->_NeSe->createLeftNode($rid, $values); + $values['STRNA'] = 'RS'.$x; + $sid = $this->_NeSe->createSubNode($rn1, $values); + $values['STRNA'] = 'RSR'.$x; + + // Try to overwrite the ROOTID which should be set inside the method + // $values['ROOTID'] = -100; + $rn2 = $this->_NeSe->createLeftNode($sid, $values); + $x++; + + $left1 = $this->_NeSe->pickNode($rn1, true); + $left2 = $this->_NeSe->pickNode($rn2, true); + + + // Root ID has to equal ID + $this->assertEquals($left1['rootid'], $left1['id'], "Left node has wrong root id."); + + // Order + $upd_rootnode = $this->_NeSe->pickNode($rid, true); + $this->assertEquals($upd_rootnode['norder'], $left1['norder'], "Left node has wrong order."); + + // Level + $this->assertEquals(1, $left1['level'], "Left node has wrong level."); + + // Children + $exp_cct = floor(($left1['r'] - $left1['l'])/2); + $allchildren = $this->_NeSe->getSubBranch($rn1, true); + + // This is also a good test if l/r values are ok + $this->assertEquals($exp_cct, count($allchildren), "Left node has wrong child count."); + + // Order + $upd_subnode = $this->_NeSe->pickNode($sid, true); + $this->assertEquals($upd_subnode['norder']-1, $left2['norder'], "Left node has wrong order."); + + // Level + $this->assertEquals(2, $left2['level'], "Left node has wrong level."); + + // Test root id + $this->assertEquals($left1['rootid'], $left2['rootid'], "Left node has wrong root id."); + } + $allnodes = $this->_NeSe->getAllNodes(true); + $this->assertEquals($rnc*4, count($allnodes), "Wrong node count after right insertion"); + return true; + } /** * tests_NestedSet_common::createSubNode__random()

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