function testTreeBehaviour() { $objDB = class_carrier::getInstance()->getObjDB(); echo "\ttesting tree-behaviour...\n"; //nr of records currently $arrSysRecords = array(); $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "system", array(), 0, false); $intNrSystemRecords = $arrRow["COUNT(*)"]; $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "system_right", array(), 0, false); //base-id echo "\tcreating root node...\n"; $objAspect = new class_module_system_aspect(); $objAspect->updateObjectToDb(); $intBaseId = $objAspect->getSystemid(); //two under the base echo "\tcreating child nodes...\n"; $objAspect = new class_module_system_aspect(); $objAspect->updateObjectToDb($intBaseId); $intSecOneId = $objAspect->getSystemid(); $objAspect = new class_module_system_aspect(); $objAspect->updateObjectToDb($intBaseId); $intSecTwoId = $objAspect->getSystemid(); $arrSysRecords[] = $intBaseId; $arrSysRecords[] = $intSecOneId; $arrSysRecords[] = $intSecTwoId; //twenty under both levels for ($intI = 0; $intI < 20; $intI++) { $objAspect = new class_module_system_aspect(); $objAspect->updateObjectToDb($intSecOneId); $arrSysRecords[] = $objAspect->getSystemid(); $objAspect = new class_module_system_aspect(); $objAspect->updateObjectToDb($intSecTwoId); $arrSysRecords[] = $objAspect->getSystemid(); $objAspect = new class_module_system_aspect(); $objAspect->updateObjectToDb($intBaseId); $arrSysRecords[] = $objAspect->getSystemid(); } //check nr of records $intCount = $objAspect->getNumberOfSiblings($intSecOneId); $this->assertEquals($intCount, 22, __FILE__ . " checkNrOfSiblingsInTree"); //check nr of childs $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "system WHERE system_prev_id = ?", array($intBaseId)); $this->assertEquals($arrRow["COUNT(*)"], 22, __FILE__ . " checkNrOfChildsInTree1"); $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "system WHERE system_prev_id = ?", array($intSecOneId)); $this->assertEquals($arrRow["COUNT(*)"], 20, __FILE__ . " checkNrOfChildsInTree2"); $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM " . _dbprefix_ . "system WHERE system_prev_id = ?", array($intSecTwoId)); $this->assertEquals($arrRow["COUNT(*)"], 20, __FILE__ . " checkNrOfChildsInTree3"); //deleting all records echo "\tdeleting nodes...\n"; foreach ($arrSysRecords as $strOneId) { $objAspect->deleteSystemRecord($strOneId); } }