Zend_Session::start(); $logger = Zend_Log::factory(array(array('writerName' => 'Stream', 'writerParams' => array('stream' => LOGS_PATH . '/testing.log'), 'filterName' => 'Priority', 'filterParams' => array('priority' => Zend_Log::DEBUG)))); Zend_Registry::set('logger', $logger); // get the config properties $configGlobal = new Zend_Config_Ini(APPLICATION_CONFIG, 'global', true); $configGlobal->environment = 'testing'; Zend_Registry::set('configGlobal', $configGlobal); $config = new Zend_Config_Ini(APPLICATION_CONFIG, 'testing'); Zend_Registry::set('config', $config); // get database type // for now only supporting MySQL, PostgreSQL, and SQLite // get the database type from the existing config files $testConfigDir = BASE_PATH . '/tests/configs/'; $dbTypes = getSqlDbTypes($testConfigDir); foreach ($dbTypes as $dbType) { try { echo 'Dropping and installing tables for database type: ' . $dbType . PHP_EOL; $dbAdapter = loadDbAdapter($testConfigDir, $dbType); dropTables($dbAdapter, $dbType); require_once BASE_PATH . '/core/controllers/components/UtilityComponent.php'; $utilityComponent = new UtilityComponent(); installCore($dbAdapter, $dbType, $utilityComponent); createDefaultAssetstore(); installModules($utilityComponent); releaseLock($dbType); } catch (Zend_Exception $ze) { echo $ze->getMessage(); exit(1); } } exit(0);
/** * @param array $modules * @param string $dir * @return int */ function installModules($modules, $dir) { if (!file_exists($dir) || !is_dir($dir)) { echo "Invalid directory {$dir}\n"; return 1; } $pkg = implode(DIRECTORY_SEPARATOR, [$dir, 'vendor', 'wwtg99', 'flight2wwu']); if (!file_exists($pkg)) { echo "No packages found in vendor, please install wwtg99/flight2wwu first!\n"; return 1; } echo "Install into {$dir}...\n"; foreach ($modules as $module) { switch ($module) { //TODO install modules case 'core': $re = installCore($dir, $pkg); break; case 'oauth': $re = installOAuth($dir, $pkg); break; case 'admin': $re = installAdmin($dir, $pkg); break; default: $re = 0; } if ($re !== 0) { echo "Install module {$module} failed!\n"; return $re; } } return 0; }