/** * Queries the packagemanager for the resolved target path, so the folder to package will be located at * after installation (or is already located at since it's already installed. * * @return mixed */ public function getStrTargetPath() { $strTarget = $this->objMetadata->getStrTarget(); if ($strTarget == "") { $strTarget = uniStrtolower(createFilename($this->objMetadata->getStrTitle(), true)); } return "/templates/" . $strTarget; }
/** * Queries the packagemanager for the resolved target path, so the folder to package will be located at * after installation (or is already located at since it's already installed. * * @return mixed */ public function getStrTargetPath() { $strTarget = $this->objMetadata->getStrTarget(); if ($strTarget == "") { $strTarget = uniStrtolower($this->objMetadata->getStrType() . "_" . createFilename($this->objMetadata->getStrTitle(), true)); } $arrModules = array_flip(class_resourceloader::getInstance()->getArrModules()); if (isset($arrModules[$strTarget])) { return "/" . $arrModules[$strTarget]; } return "/core/" . $strTarget; }
public function testExtractAndMove() { $objFilesystem = new class_filesystem(); $objFilesystem->folderCreate(_projectpath_ . "/temp/moduletest"); file_put_contents(_realpath_ . _projectpath_ . "/temp/moduletest/metadata.xml", $this->getStrMetadata()); $objFilesystem->folderCreate(_projectpath_ . "/temp/moduletest/system"); file_put_contents(_realpath_ . _projectpath_ . "/temp/moduletest/system/test.txt", $this->getStrMetadata()); $objZip = new class_zip(); $objZip->openArchiveForWriting(_projectpath_ . "/temp/autotest.zip"); $objZip->addFile(_projectpath_ . "/temp/moduletest/metadata.xml", "/metadata.xml"); $objZip->addFile(_projectpath_ . "/temp/moduletest/system/test.txt", "/system/test.txt"); $objZip->closeArchive(); $objFilesystem->folderDeleteRecursive(_projectpath_ . "/temp/moduletest/"); $objManager = new class_module_packagemanager_manager(); $objPackageManager = $objManager->getPackageManagerForPath(_projectpath_ . "/temp/autotest.zip"); $this->assertEquals(get_class($objPackageManager), "class_module_packagemanager_packagemanager_module"); $objPackageManager = $objManager->extractPackage(_projectpath_ . "/temp/autotest.zip"); $this->assertEquals(get_class($objPackageManager), "class_module_packagemanager_packagemanager_module"); $objPackageManager->move2Filesystem(); $this->assertFileExists(_realpath_ . "/core/module_autotest/metadata.xml"); $this->assertFileExists(_realpath_ . "/core/module_autotest/system/test.txt"); $objMetadata = new class_module_packagemanager_metadata(); $objMetadata->autoInit("/core/module_autotest/"); $this->assertEquals("Autotest", $objMetadata->getStrTitle()); $this->assertEquals("", $objMetadata->getStrDescription()); $this->assertEquals("3.9.1", $objMetadata->getStrVersion()); $this->assertEquals("Kajona Team", $objMetadata->getStrAuthor()); $this->assertEquals("module_autotest", $objMetadata->getStrTarget()); $this->assertEquals(class_module_packagemanager_manager::STR_TYPE_MODULE, $objMetadata->getStrType()); $this->assertEquals(false, $objMetadata->getBitProvidesInstaller()); $arrRequired = $objMetadata->getArrRequiredModules(); $arrModules = array_keys($arrRequired); $arrVersion = array_values($arrRequired); $this->assertEquals("system", $arrModules[0]); $this->assertEquals("3.4.1", $arrVersion[0]); $this->assertEquals("pages", $arrModules[1]); $this->assertEquals("3.4.2", $arrVersion[1]); $arrImages = $objMetadata->getArrScreenshots(); $this->assertEquals(1, count($arrImages)); $this->assertEquals("/test.jpg", $arrImages[0]); $objFilesystem->folderDeleteRecursive("/core/module_autotest"); $objFilesystem->fileDelete(_projectpath_ . "/temp/autotest.zip"); }