public function testImportExport() { class_carrier::getInstance()->getObjRights()->setBitTestMode(true); $strName = generateSystemid(); $strBrowsername = generateSystemid(); $strSeoString = generateSystemid(); $strDesc = generateSystemid(); $objPage = new class_module_pages_page(); $objPage->setStrName($strName); $objPage->setStrBrowsername($strBrowsername); $objPage->setStrSeostring($strSeoString); $objPage->setStrDesc($strDesc); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb(); $strPagesystemid = $objPage->getSystemid(); $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("text_paragraph"); $objPagelement->setStrName("text"); $objPagelement->setStrElement("paragraph"); $objPagelement->updateObjectToDb($objPage->getSystemid()); $objElement = new class_element_paragraph_admin($objPagelement->getSystemid()); $objElement->setSystemid($objPagelement->getSystemid()); $objElement->loadElementData(); $objElement->setStrTitle("para_title"); $objElement->updateForeignElement(); $objPagelement = new class_module_pages_pageelement($objPagelement->getSystemid()); class_carrier::getInstance()->setParam("pageExport", $strName); $objPageExport = new class_systemtask_pageexport(); $objPageExport->executeTask(); $objPage->deleteObjectFromDatabase(); class_orm_rowcache::flushCache(); class_db::getInstance()->flushQueryCache(); $this->assertNull(class_module_pages_page::getPageByName($strName)); $this->assertFileExists(_realpath_ . _projectpath_ . "/temp/" . $strPagesystemid . ".xml"); class_carrier::getInstance()->setParam("pageimport_file", _projectpath_ . "/temp/" . $strPagesystemid . ".xml"); $objImport = new class_systemtask_pageimport(); $objImport->executeTask(); $objPage = class_module_pages_page::getPageByName($strName); $this->assertNotNull($objPage); $this->assertEquals($objPage->getStrName(), $strName); $this->assertEquals($objPage->getStrDesc(), $strDesc); $this->assertEquals($objPage->getStrSeostring(), $strSeoString); $this->assertEquals($objPage->getStrBrowsername(), $strBrowsername); $objElements = class_module_pages_pageelement::getAllElementsOnPage($objPage->getSystemid()); $this->assertEquals(1, count($objElements)); $objElements = $objElements[0]; $this->assertEquals($objElements->getStrClassAdmin(), "class_element_paragraph_admin.php"); $objElement = $objElements->getConcreteAdminInstance(); $objElement->setSystemid($objElements->getSystemid()); $objElement->loadElementData(); $this->assertEquals("para_title", $objElement->getStrTitle()); $objPage->deleteObjectFromDatabase(); }
public function testCopyPage() { $strTitle = generateSystemid(); $objPage = new class_module_pages_page(); $objPage->setStrName($strTitle); $objPage->setStrBrowsername(generateSystemid()); $objPage->setStrSeostring(generateSystemid()); $objPage->setStrDesc(generateSystemid()); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb(); $strOldSystemid = $objPage->getSystemid(); $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("text_paragraph"); $objPagelement->setStrName("text"); $objPagelement->setStrElement("paragraph"); $objPagelement->updateObjectToDb($objPage->getSystemid()); $objPagelement = new class_module_pages_pageelement($objPagelement->getSystemid()); //and finally create the object /** @var $objElement class_element_paragraph_admin */ $objElement = $objPagelement->getConcreteAdminInstance(); $objElement->setStrTitle("autotest"); $objElement->doBeforeSaveToDb(); $objElement->updateForeignElement(); $objElement->doAfterSaveToDb(); //copy the page itself $objPage->copyObject(); $strNewSystemid = $objPage->getSystemid(); $this->flushDBCache(); $objOldPage = new class_module_pages_page($strOldSystemid); $objNewPage = new class_module_pages_page($strNewSystemid); $this->assertNotEquals($objOldPage->getStrName(), $objNewPage->getStrName()); $this->assertEquals($objOldPage->getStrBrowsername(), $objNewPage->getStrBrowsername()); $this->assertEquals($objOldPage->getStrSeostring(), $objNewPage->getStrSeostring()); $this->assertEquals($objOldPage->getStrDesc(), $objNewPage->getStrDesc()); $this->assertEquals($objOldPage->getStrTemplate(), $objNewPage->getStrTemplate()); $arrOldElements = class_module_pages_pageelement::getAllElementsOnPage($strOldSystemid); $arrNewElements = class_module_pages_pageelement::getAllElementsOnPage($strNewSystemid); $this->assertEquals(count($arrOldElements), count($arrNewElements)); $this->assertEquals(1, count($arrOldElements)); $this->assertEquals(1, count($arrNewElements)); $objOldElement = $arrOldElements[0]; $objNewElement = $arrNewElements[0]; $this->assertEquals($objOldElement->getStrPlaceholder(), $objNewElement->getStrPlaceholder()); $this->assertEquals($objOldElement->getStrLanguage(), $objNewElement->getStrLanguage()); $this->assertEquals($objOldElement->getStrElement(), $objNewElement->getStrElement()); /** @var class_element_paragraph_admin $objOldElementInstance */ $objOldElementInstance = $objOldElement->getConcreteAdminInstance(); $arrOldElementData = $objOldElementInstance->loadElementData(); /** @var class_element_paragraph_admin $objNewElementInstance */ $objNewElementInstance = $objNewElement->getConcreteAdminInstance(); $arrNewElementData = $objNewElementInstance->loadElementData(); $this->assertNotEquals($arrOldElementData["content_id"], $arrNewElementData["content_id"]); $this->assertEquals($arrOldElementData["paragraph_title"], $arrNewElementData["paragraph_title"]); $this->assertEquals($objOldElementInstance->getStrTitle(), $objNewElementInstance->getStrTitle()); $this->assertEquals($objOldElementInstance->getStrTitle(), "autotest"); $this->assertEquals($objNewElementInstance->getStrTitle(), "autotest"); $objNewPage->deleteObjectFromDatabase(); $objOldPage->deleteObjectFromDatabase(); }
public function testPageElementDeleteSortingMultiLanguage() { $objPage = new class_module_pages_page(); $objPage->setStrName("sortTest"); $objPage->updateObjectToDb(); $objPagelementb1 = new class_module_pages_pageelement(); $objPagelementb1->setStrPlaceholder("b_test"); $objPagelementb1->setStrName("b"); $objPagelementb1->setStrElement("row"); $objPagelementb1->setStrLanguage("a1"); $objPagelementb1->updateObjectToDb($objPage->getSystemid()); $objPagelementc1 = new class_module_pages_pageelement(); $objPagelementc1->setStrPlaceholder("b_test"); $objPagelementc1->setStrName("b"); $objPagelementc1->setStrElement("row"); $objPagelementc1->setStrLanguage("a2"); $objPagelementc1->updateObjectToDb($objPage->getSystemid()); $objPagelementb2 = new class_module_pages_pageelement(); $objPagelementb2->setStrPlaceholder("b_test"); $objPagelementb2->setStrName("b"); $objPagelementb2->setStrElement("row"); $objPagelementb2->setStrLanguage("a1"); $objPagelementb2->updateObjectToDb($objPage->getSystemid()); $objPagelementb3 = new class_module_pages_pageelement(); $objPagelementb3->setStrPlaceholder("b_test"); $objPagelementb3->setStrName("b"); $objPagelementb3->setStrElement("row"); $objPagelementb3->setStrLanguage("a1"); $objPagelementb3->updateObjectToDb($objPage->getSystemid()); $objPagelementc2 = new class_module_pages_pageelement(); $objPagelementc2->setStrPlaceholder("b_test"); $objPagelementc2->setStrName("b"); $objPagelementc2->setStrElement("row"); $objPagelementc2->setStrLanguage("a2"); $objPagelementc2->updateObjectToDb($objPage->getSystemid()); $objPagelementc3 = new class_module_pages_pageelement(); $objPagelementc3->setStrPlaceholder("b_test"); $objPagelementc3->setStrName("b"); $objPagelementc3->setStrElement("row"); $objPagelementc3->setStrLanguage("a2"); $objPagelementc3->updateObjectToDb($objPage->getSystemid()); $arrElements = class_module_pages_pageelement::getElementsByPlaceholderAndPage($objPage->getSystemid(), "b_test", "a1", false); $this->assertEquals(3, count($arrElements)); $this->assertEquals(1, $arrElements[0]->getIntSort()); $this->assertEquals($objPagelementb1->getSystemid(), $arrElements[0]->getSystemid()); $this->assertEquals(2, $arrElements[1]->getIntSort()); $this->assertEquals($objPagelementb2->getSystemid(), $arrElements[1]->getSystemid()); $this->assertEquals(3, $arrElements[2]->getIntSort()); $this->assertEquals($objPagelementb3->getSystemid(), $arrElements[2]->getSystemid()); $arrElements = class_module_pages_pageelement::getElementsByPlaceholderAndPage($objPage->getSystemid(), "b_test", "a2", false); $this->assertEquals(3, count($arrElements)); $this->assertEquals(1, $arrElements[0]->getIntSort()); $this->assertEquals($objPagelementc1->getSystemid(), $arrElements[0]->getSystemid()); $this->assertEquals(2, $arrElements[1]->getIntSort()); $this->assertEquals($objPagelementc2->getSystemid(), $arrElements[1]->getSystemid()); $this->assertEquals(3, $arrElements[2]->getIntSort()); $this->assertEquals($objPagelementc3->getSystemid(), $arrElements[2]->getSystemid()); $objPagelementb2->deleteObjectFromDatabase(); $this->flushDBCache(); $arrElements = class_module_pages_pageelement::getElementsByPlaceholderAndPage($objPage->getSystemid(), "b_test", "a1", false); $this->assertEquals(2, count($arrElements)); $this->assertEquals(1, $arrElements[0]->getIntSort()); $this->assertEquals($objPagelementb1->getSystemid(), $arrElements[0]->getSystemid()); $this->assertEquals(2, $arrElements[1]->getIntSort()); $this->assertEquals($objPagelementb3->getSystemid(), $arrElements[1]->getSystemid()); $arrElements = class_module_pages_pageelement::getElementsByPlaceholderAndPage($objPage->getSystemid(), "b_test", "a2", false); $this->assertEquals(3, count($arrElements)); $this->assertEquals(1, $arrElements[0]->getIntSort()); $this->assertEquals($objPagelementc1->getSystemid(), $arrElements[0]->getSystemid()); $this->assertEquals(2, $arrElements[1]->getIntSort()); $this->assertEquals($objPagelementc2->getSystemid(), $arrElements[1]->getSystemid()); $this->assertEquals(3, $arrElements[2]->getIntSort()); $this->assertEquals($objPagelementc3->getSystemid(), $arrElements[2]->getSystemid()); $objPage->deleteObjectFromDatabase(); }
public function tearDown() { class_carrier::getInstance()->getObjDB()->flushQueryCache(); //delete pages and folders created $objPage = new class_module_pages_page(self::$strPage2aSystemid); $objPage->deleteObjectFromDatabase(); $objPage = new class_module_pages_page(self::$strPage2Systemid); $objPage->deleteObjectFromDatabase(); $objPage = new class_module_pages_page(self::$strPage1Systemid); $objPage->deleteObjectFromDatabase(); $objFolder = new class_module_pages_folder(self::$strFolderSystemid); $objFolder->deleteObjectFromDatabase(); parent::tearDown(); }
public function testRandomSortTest() { $objRootPage = new class_module_pages_page(); $objRootPage->setStrName("randomSortTest"); $objRootPage->updateObjectToDb(); $arrNodes = array(); for ($intI = 0; $intI < 5; $intI++) { $objPage = new class_module_pages_page(); $objPage->setStrName("l1_" . $intI); $objPage->updateObjectToDb($objRootPage->getSystemid()); $arrNodes[] = $objPage->getSystemid(); for ($intK = 0; $intK < 10; $intK++) { $objPageK = new class_module_pages_page(); $objPageK->setStrName("l2_" . $intI); $objPageK->updateObjectToDb($objPage->getSystemid()); $arrNodes[] = $objPageK->getSystemid(); } } $intMax = count($arrNodes) - 1; for ($intI = 0; $intI < 50; $intI++) { $objPage = new class_module_pages_page($arrNodes[rand(0, $intMax)]); $objPage->updateObjectToDb($arrNodes[rand(0, $intMax)]); } $this->validateSingleLevelSort($objRootPage->getSystemid()); $objRootPage->deleteObjectFromDatabase(); }