From: Michael M Slusarz Date: Wed, 5 Jan 2011 08:36:13 +0000 (-0700) Subject: Allow running test script if app does not yet have conf.php file X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5d0b4fef24514cd416d7caf0133f1c298df24284;p=horde.git Allow running test script if app does not yet have conf.php file --- diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 3ec128815..bb5cc0b6d 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -71,6 +71,13 @@ class Horde_Registry protected $_apiList = array(); /** + * The arguments that have been passed when instantiating the registry. + * + * @var array + */ + protected $_args = array(); + + /** * Cached configuration information. * * @var array @@ -106,13 +113,6 @@ class Horde_Registry protected $_vhost = null; /** - * The arguments that have been passed when instantiating the registry. - * - * @var array - */ - protected $_args = array(); - - /** * Application bootstrap initialization. * Solves chicken-and-egg problem - need a way to init Horde environment * from application without an active Horde_Registry object. @@ -155,6 +155,9 @@ class Horde_Registry * 'none' - Do not start a session * 'readonly' - Start session readonly * [DEFAULT] - Start read/write session + * 'test' - (boolean) Is this the test script? If so, we relax several + * sanity checks and don't load things from the cache. + * DEFAULT: false * 'timezone' - (boolean) Set the time zone? * DEFAULT: false * 'user_admin' - (boolean) Set authentication to an admin user? @@ -564,7 +567,8 @@ class Horde_Registry if (!isset($app['name'])) { $app['name'] = ''; } elseif (!file_exists($app['fileroot']) || - (file_exists($app['fileroot'] . '/config/conf.xml') && + (empty($this->_args['test']) && + file_exists($app['fileroot'] . '/config/conf.xml') && !file_exists($app['fileroot'] . '/config/conf.php'))) { $app['status'] = 'inactive'; Horde::logMessage('Setting ' . $appName . ' inactive because the fileroot does not exist or the application is not configured yet.', 'DEBUG'); @@ -1582,7 +1586,8 @@ class Horde_Registry */ protected function _loadCache($name) { - if ($id = $this->_getCacheId($name)) { + if (empty($this->_args['test']) && + ($id = $this->_getCacheId($name))) { $result = $GLOBALS['injector']->getInstance('Horde_Cache')->get($id, 86400); if ($result !== false) { Horde::logMessage(__CLASS__ . ': retrieved ' . $name . ' with cache ID ' . $id, 'DEBUG'); @@ -1622,6 +1627,10 @@ class Horde_Registry */ protected function _saveCache($key, $data = null) { + if (!empty($this->_args['test'])) { + return; + } + $ob = $GLOBALS['injector']->getInstance('Horde_Cache'); if (is_null($data)) { diff --git a/horde/test.php b/horde/test.php index 5b14f82f8..3ff5eeced 100644 --- a/horde/test.php +++ b/horde/test.php @@ -42,7 +42,10 @@ if (!file_exists(dirname(__FILE__) . '/config/registry.php')) { require_once dirname(__FILE__) . '/lib/Application.php'; try { - Horde_Registry::appInit('horde', array('authentication' => 'none')); + Horde_Registry::appInit('horde', array( + 'authentication' => 'none', + 'test' => true + )); $init_exception = null; } catch (Exception $e) { define('HORDE_TEMPLATES', dirname(__FILE__) . '/templates');