public function testLockExceptionOnSort()
 {
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("test");
     $objAspect->updateObjectToDb();
     $strAspectId = $objAspect->getSystemid();
     $objUser1 = new class_module_user_user();
     $objUser1->setStrUsername(generateSystemid());
     $objUser1->setIntActive(1);
     $objUser1->updateObjectToDb();
     $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser1));
     $objAspect->getLockManager()->lockRecord();
     $this->assertTrue($objAspect->getLockManager()->isLockedByCurrentUser());
     $objUser2 = new class_module_user_user();
     $objUser2->setStrUsername(generateSystemid());
     $objUser2->setIntActive(1);
     $objUser2->updateObjectToDb();
     $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser2));
     $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser());
     $intSort = $objAspect->getIntSort();
     $objException = null;
     try {
         $objAspect->setAbsolutePosition(4);
     } catch (class_exception $objEx) {
         $objException = $objEx;
     }
     $this->assertNotNull($objException);
     $this->assertEquals($intSort, $objAspect->getIntSort());
     class_carrier::getInstance()->getObjSession()->logout();
     $objAspect = new class_module_system_aspect($strAspectId);
     $objAspect->deleteObjectFromDatabase();
     $objUser1->deleteObjectFromDatabase();
     $objUser2->deleteObjectFromDatabase();
 }
 function testTreeSortBehaviour()
 {
     $objDB = class_carrier::getInstance()->getObjDB();
     //test the setToPos
     echo "\tposition handling...\n";
     //create 10 test records
     $objAspect = new class_module_system_aspect();
     //new base-node
     $objAspect->updateObjectToDb();
     $strBaseNodeId = $objAspect->getSystemid();
     $arrNodes = array();
     for ($intI = 1; $intI <= 10; $intI++) {
         $objAspect = new class_module_system_aspect();
         $objAspect->updateObjectToDb($strBaseNodeId);
         $arrNodes[] = $objAspect->getSystemid();
     }
     //initial movings
     $objAspect = new class_module_system_aspect($arrNodes[1]);
     $objAspect->setPosition("upwards");
     $arrNodes = $objDB->getPArray("SELECT system_id FROM " . _dbprefix_ . "system WHERE system_prev_id = ? ORDER BY system_sort ASC", array($strBaseNodeId));
     echo "\trelative shiftings...\n";
     //move the third to the first pos
     $objAspect = new class_module_system_aspect($arrNodes[2]["system_id"]);
     $objAspect->setPosition("upwards");
     $objAspect->setPosition("upwards");
     $objAspect->setPosition("upwards");
     //next one should be with no effect
     $objAspect->setPosition("upwards");
     $objDB->flushQueryCache();
     $arrNodesAfter = $objDB->getPArray("SELECT system_id FROM " . _dbprefix_ . "system WHERE system_prev_id = ? ORDER BY system_sort ASC", array($strBaseNodeId));
     $this->assertEquals($arrNodesAfter[0]["system_id"], $arrNodes[2]["system_id"], __FILE__ . " checkPositionShitftingByRelativeShift");
     $this->assertEquals($arrNodesAfter[1]["system_id"], $arrNodes[0]["system_id"], __FILE__ . " checkPositionShitftingByRelativeShift");
     $this->assertEquals($arrNodesAfter[2]["system_id"], $arrNodes[1]["system_id"], __FILE__ . " checkPositionShitftingByRelativeShift");
     //moving by set pos
     echo "\tabsolute shifting..\n";
     $objDB->flushQueryCache();
     $arrNodes = $objDB->getPArray("SELECT system_id FROM " . _dbprefix_ . "system WHERE system_prev_id = ? ORDER BY system_sort ASC", array($strBaseNodeId));
     $objDB->flushQueryCache();
     $objAspect = new class_module_system_aspect($arrNodes[2]["system_id"]);
     $objAspect->setAbsolutePosition(1);
     $arrNodesAfter = $objDB->getPArray("SELECT system_id FROM " . _dbprefix_ . "system WHERE system_prev_id = ? ORDER BY system_sort ASC", array($strBaseNodeId));
     $this->assertEquals($arrNodesAfter[0]["system_id"], $arrNodes[2]["system_id"], __FILE__ . " checkPositionShitftingByAbsoluteShift");
     $this->assertEquals($arrNodesAfter[1]["system_id"], $arrNodes[0]["system_id"], __FILE__ . " checkPositionShitftingByAbsoluteShift");
     $this->assertEquals($arrNodesAfter[2]["system_id"], $arrNodes[1]["system_id"], __FILE__ . " checkPositionShitftingByAbsoluteShift");
     //and back...
     $objDB->flushQueryCache();
     $objAspect = new class_module_system_aspect($arrNodes[2]["system_id"]);
     $objAspect->setAbsolutePosition(3);
     $objDB->flushQueryCache();
     $arrNodesAfter = $objDB->getPArray("SELECT system_id FROM " . _dbprefix_ . "system WHERE system_prev_id = ? ORDER BY system_sort ASC", array($strBaseNodeId));
     $this->assertEquals($arrNodesAfter[0]["system_id"], $arrNodes[0]["system_id"], __FILE__ . " checkPositionShitftingByAbsoluteShift");
     $this->assertEquals($arrNodesAfter[1]["system_id"], $arrNodes[1]["system_id"], __FILE__ . " checkPositionShitftingByAbsoluteShift");
     $this->assertEquals($arrNodesAfter[2]["system_id"], $arrNodes[2]["system_id"], __FILE__ . " checkPositionShitftingByAbsoluteShift");
     //deleting all records created
     foreach ($arrNodes as $arrOneNode) {
         $objAspect = new class_module_system_aspect($arrOneNode["system_id"]);
         $objAspect->deleteObjectFromDatabase();
     }
     $objAspect = new class_module_system_aspect($strBaseNodeId);
     $objAspect->deleteObjectFromDatabase();
 }