public function testEventHandler()
 {
     self::$bitHandled = false;
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("test");
     $objAspect->updateObjectToDb();
     class_core_eventdispatcher::getInstance()->addListener(class_system_eventidentifier::EVENT_SYSTEM_STATUSCHANGED, new class_test_statuchangedhandler($objAspect->getSystemid(), $this));
     $this->assertTrue(!self::$bitHandled);
     $objAspect->setIntRecordStatus(0);
     $this->assertTrue(!self::$bitHandled);
     $objAspect->updateObjectToDb();
     $this->assertTrue(self::$bitHandled);
     $objAspect->deleteObjectFromDatabase();
 }
Beispiel #2
0
 public function testTagAssignmentRemoval()
 {
     //related to checkin #6111
     $objTag = new class_module_tags_tag();
     $objTag->setStrName(generateSystemid());
     $objTag->updateObjectToDb();
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName(generateSystemid());
     $objAspect->updateObjectToDb();
     $objTag->assignToSystemrecord($objAspect->getSystemid());
     $this->flushDBCache();
     $this->assertEquals(count($objTag->getArrAssignedRecords()), 1);
     $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid())), 1);
     $objTag->removeFromSystemrecord($objAspect->getSystemid(), "");
     $this->flushDBCache();
     $this->assertEquals(count($objTag->getArrAssignedRecords()), 0);
     $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid())), 0);
     $objTag->deleteObjectFromDatabase();
     $objAspect->deleteObjectFromDatabase();
 }
 public function testIndexEvent()
 {
     if (class_module_system_module::getModuleByName("tags") == null || class_module_system_module::getModuleByName("system") == null) {
         return;
     }
     $strSearchKey1 = generateSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName($strSearchKey1);
     $objAspect->updateObjectToDb();
     $objSearchCommons = new class_module_search_commons();
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey1);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid());
     $strSearchKey2 = generateSystemid();
     $objTag = new class_module_tags_tag();
     $objTag->setStrName($strSearchKey2);
     $objTag->updateObjectToDb();
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey2);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid());
     $objTag->assignToSystemrecord($objAspect->getStrSystemid());
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 2);
     $objSearchParams->setStrInternalFilterModules(_system_modul_id_);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objAspect->getStrSystemid());
     $objTag->removeFromSystemrecord($objAspect->getStrSystemid());
     //the aspect itself should not be found any more
     $objSearchParams = new class_module_search_search();
     $objSearchParams->setStrQuery($strSearchKey2);
     $arrResult = $objSearchCommons->doIndexedSearch($objSearchParams, null);
     $this->assertEquals(count($arrResult), 1);
     $this->assertEquals($arrResult[0]->getObjObject()->getStrSystemid(), $objTag->getStrSystemid());
     $objAspect->deleteObjectFromDatabase();
     $objTag->deleteObjectFromDatabase();
 }
 public function testLogicalDelete()
 {
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::INCLUDED());
     $intCountTotal = class_module_system_aspect::getObjectCount();
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED());
     $intCountActive = class_module_system_aspect::getObjectCount();
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUSIVE());
     $intCountDeleted = class_module_system_aspect::getObjectCount();
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED());
     echo "Creating aspect\n";
     $objAspect1 = new class_module_system_aspect();
     $objAspect1->setStrName("Dummy");
     $objAspect1->updateObjectToDb();
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("logical delete");
     $objAspect->updateObjectToDb();
     $strAspectId = $objAspect->getSystemid();
     $this->assertEquals($intCountActive + 2, class_module_system_aspect::getObjectCount());
     $arrAspects = class_module_system_aspect::getObjectList();
     $arrAspects = array_filter($arrAspects, function (class_module_system_aspect $objAspect) use($strAspectId) {
         return $objAspect->getSystemid() == $strAspectId;
     });
     $this->assertEquals(1, count($arrAspects));
     echo "Deleting logically\n";
     $this->assertEquals($objAspect->getIntRecordDeleted(), 0);
     $objAspect->deleteObject();
     $this->assertEquals($objAspect->getIntRecordDeleted(), 1);
     $this->assertEquals($objAspect->getIntSort(), -1);
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED());
     echo "Loading non-deleted only\n";
     $this->assertEquals($intCountActive + 1, class_module_system_aspect::getObjectCount());
     $arrAspects = class_module_system_aspect::getObjectList();
     $arrAspects = array_filter($arrAspects, function (class_module_system_aspect $objAspect) use($strAspectId) {
         return $objAspect->getSystemid() == $strAspectId;
     });
     $this->assertEquals(0, count($arrAspects));
     echo "Loading deleted only\n";
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUSIVE());
     $arrAspects = class_module_system_aspect::getObjectList();
     $arrAspects = array_filter($arrAspects, function (class_module_system_aspect $objAspect) use($strAspectId) {
         return $objAspect->getSystemid() == $strAspectId;
     });
     $this->assertEquals($intCountDeleted + 1, class_module_system_aspect::getObjectCount());
     $this->assertEquals(1, count($arrAspects));
     echo "Loading mixed deleted and non-deleted\n";
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::INCLUDED());
     $arrAspects = class_module_system_aspect::getObjectList();
     $arrAspects = array_filter($arrAspects, function (class_module_system_aspect $objAspect) use($strAspectId) {
         return $objAspect->getSystemid() == $strAspectId;
     });
     $this->assertEquals($intCountTotal + 2, class_module_system_aspect::getObjectCount());
     $this->assertEquals(1, count($arrAspects));
     echo "Deleting from database\n";
     $objAspect->deleteObjectFromDatabase();
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED());
     echo "Loading non-deleted only\n";
     $this->assertEquals($intCountActive + 1, class_module_system_aspect::getObjectCount());
     $arrAspects = class_module_system_aspect::getObjectList();
     $arrAspects = array_filter($arrAspects, function (class_module_system_aspect $objAspect) use($strAspectId) {
         return $objAspect->getSystemid() == $strAspectId;
     });
     $this->assertEquals(0, count($arrAspects));
     echo "Loading deleted only\n";
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUSIVE());
     $arrAspects = class_module_system_aspect::getObjectList();
     $arrAspects = array_filter($arrAspects, function (class_module_system_aspect $objAspect) use($strAspectId) {
         return $objAspect->getSystemid() == $strAspectId;
     });
     $this->assertEquals($intCountDeleted, class_module_system_aspect::getObjectCount());
     $this->assertEquals(0, count($arrAspects));
     echo "Deleting dummy node directly\n";
     $objAspect1->deleteObjectFromDatabase();
     echo "Loading non-deleted only\n";
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED());
     $this->assertEquals($intCountActive, class_module_system_aspect::getObjectCount());
     echo "Loading deleted only\n";
     class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUSIVE());
     $this->assertEquals($intCountDeleted, class_module_system_aspect::getObjectCount());
 }
Beispiel #5
0
 public function testTreeDelete()
 {
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb("0");
     $strRootNodeId = $objAspect->getSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb($strRootNodeId);
     $strSub1Node1Id = $objAspect->getSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb($strRootNodeId);
     $strSub1Node2Id = $objAspect->getSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb($strRootNodeId);
     $strSub1Node2Id = $objAspect->getSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb($strSub1Node1Id);
     $strSub2Node1aId = $objAspect->getSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb($strSub1Node1Id);
     $strSub2Node1bId = $objAspect->getSystemid();
     $objAspect = new class_module_system_aspect();
     $objAspect->updateObjectToDb($strSub1Node1Id);
     $strSub2Node1cId = $objAspect->getSystemid();
     $this->assertEquals(3, count($objAspect->getChildNodesAsIdArray($strRootNodeId)));
     $this->assertEquals(3, count($objAspect->getChildNodesAsIdArray($strSub1Node1Id)));
     $objAspect = new class_module_system_aspect($strRootNodeId);
     $objAspect->deleteObjectFromDatabase();
     class_db::getInstance()->flushQueryCache();
     $this->assertEquals(0, count($objAspect->getChildNodesAsIdArray($strRootNodeId)));
     $this->assertEquals(0, count($objAspect->getChildNodesAsIdArray($strSub1Node1Id)));
 }
 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();
 }
Beispiel #8
0
 public function testAddGroupToPermission()
 {
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("democase");
     $objAspect->updateObjectToDb();
     $strGroupId = generateSystemid();
     //fill caches
     class_module_system_aspect::getObjectList();
     $arrRow = class_carrier::getInstance()->getObjDB()->getPRow("SELECT * FROM " . _dbprefix_ . "system_right WHERE right_id = ?", array($objAspect->getSystemid()), 0, false);
     $this->assertTrue(!in_array($strGroupId, explode(",", $arrRow["right_view"])));
     $this->assertTrue(!class_carrier::getInstance()->getObjRights()->checkPermissionForGroup($strGroupId, class_rights::$STR_RIGHT_VIEW, $objAspect->getSystemid()));
     class_carrier::getInstance()->getObjRights()->addGroupToRight($strGroupId, $objAspect->getSystemid(), class_rights::$STR_RIGHT_VIEW);
     $arrRow = class_carrier::getInstance()->getObjDB()->getPRow("SELECT * FROM " . _dbprefix_ . "system_right WHERE right_id = ?", array($objAspect->getSystemid()), 0, false);
     $this->assertTrue(in_array($strGroupId, explode(",", $arrRow["right_view"])));
     $this->assertTrue(class_carrier::getInstance()->getObjRights()->checkPermissionForGroup($strGroupId, class_rights::$STR_RIGHT_VIEW, $objAspect->getSystemid()));
     class_module_system_aspect::getObjectList();
     $arrRow = class_carrier::getInstance()->getObjDB()->getPRow("SELECT * FROM " . _dbprefix_ . "system_right WHERE right_id = ?", array($objAspect->getSystemid()), 0, false);
     $this->assertTrue(in_array($strGroupId, explode(",", $arrRow["right_view"])));
     $this->assertTrue(class_carrier::getInstance()->getObjRights()->checkPermissionForGroup($strGroupId, class_rights::$STR_RIGHT_VIEW, $objAspect->getSystemid()));
     $objAspect->deleteObjectFromDatabase();
 }