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 testCopyRecordWithTag() { $objAspect = new class_module_system_aspect(); $objAspect->setStrName("autotest"); $objAspect->updateObjectToDb(); $objTag = new class_module_tags_tag(); $objTag->setStrName("demo tag"); $objTag->updateObjectToDb(); $objTag->assignToSystemrecord($objAspect->getStrSystemid()); $objFirstAspect = new class_module_system_aspect($objAspect->getSystemid()); $objAspect->copyObject(); $this->assertNotEquals($objFirstAspect->getSystemid(), $objAspect->getSystemid()); $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objFirstAspect->getSystemid())), count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid()))); $arrTagsFirst = class_module_tags_tag::getTagsForSystemid($objFirstAspect->getSystemid()); $objFirstTag = $arrTagsFirst[0]; $arrTagsCopy = class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid()); $objSecondTag = $arrTagsCopy[0]; $this->assertEquals($objFirstTag->getSystemid(), $objSecondTag->getSystemid()); $objFirstAspect->deleteObjectFromDatabase(); $objAspect->deleteObjectFromDatabase(); $objSecondTag->deleteObjectFromDatabase(); }