Пример #1
0
 /**
  * Do required initialization for tests.
  */
 public function __construct()
 {
     global $UBAR_GLOB;
     require_once dirname(__FILE__) . "/../functions/misc.php";
     // allow the following folders of classes to be auto-loaded
     if (!isset($UBAR_GLOB['UBAR_ROOT'])) {
         $UBAR_GLOB['UBAR_ROOT'] = realpath(dirname(__FILE__) . "/../") . DIRECTORY_SEPARATOR;
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "constants", TRUE);
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "exception", TRUE);
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "core", TRUE);
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "test", TRUE);
     }
     parent::__construct();
 }
Пример #2
0
/**
 * Assign folders as search locations for class autoloading.
 *
 * @param string $directory Directory to add to search list.
 * @param boolean $recursive Whether the search directory should be recursively
 * added to search list.
 */
function getClassPaths($directory, $recursive = FALSE)
{
    global $classes;
    $dir = opendir($directory);
    while ($entry = readdir($dir)) {
        if ($entry != "." && $entry != ".." && !(strstr($entry, '.svn') > -1)) {
            $file = $directory . '/' . $entry;
            if (is_dir($file) && $recursive) {
                getClassPaths($file, $recursive);
            } elseif (is_file($file) && substr($file, strlen($file) - 4, 4) == '.php') {
                $classes[$entry] = $directory . '/' . $entry;
            }
        }
    }
}
Пример #3
0
 /**
  * Do test setup, simulates the bootstrapping that is required for
  * framework functionality.
  *
  * Dev mode is overridden to true and locale set to english.
  *
  * @param string $name Pass through for argument in PHPUnit_Framework_TestCase
  * @param array $data Pass through for argument in PHPUnit_Framework_TestCase
  * @param string $dataName Pass through for argument in PHPUnit_Framework_TestCase
  */
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     global $UBAR_GLOB;
     $UBAR_GLOB['DEV_MODE'] = true;
     require_once dirname(__FILE__) . "/../functions/misc.php";
     // allow the following folders of classes to be auto-loaded
     if (!isset($UBAR_GLOB['UBAR_ROOT'])) {
         $UBAR_GLOB['UBAR_ROOT'] = realpath(dirname(__FILE__) . "/../") . DIRECTORY_SEPARATOR;
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "constants", TRUE);
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "exception", TRUE);
         getClassPaths($UBAR_GLOB['UBAR_ROOT'] . "core", TRUE);
     }
     // defualt to us english, if you need to change locally, might need to reset when done with test
     setlocale(LC_ALL, 'english-usa', 'en_US.utf8');
     parent::__construct($name, $data, $dataName);
 }
Пример #4
0
 * @see GlobalConstants::BASE_VIEW_PATH
 */
$UBAR_GLOB['BASE_VIEW_PATH'] = $UBAR_GLOB['UBAR_ROOT'] . "/" . $props->get('BASE_VIEW_PATH' . $UBAR_GLOB['PROP_APPEND'], GlobalConstants::BASE_VIEW_PATH);
if (!is_dir($UBAR_GLOB['BASE_VIEW_PATH'])) {
    throw new Exception("Unable to find specified view root path at \"" . $UBAR_GLOB['BASE_VIEW_PATH'] . "\".");
}
/**
 * Define path to model folder. This is an optional convenience for autoloading
 * model classes.
 *
 * @todo Consider just having an autoload directory or easier addition of autoload folders.
 * @see GlobalConstants::BASE_MODEL_PATH
 */
$UBAR_GLOB['BASE_MODEL_PATH'] = $UBAR_GLOB['UBAR_ROOT'] . "/" . $props->get('BASE_MODEL_PATH' . $UBAR_GLOB['PROP_APPEND'], GlobalConstants::BASE_MODEL_PATH);
if (is_dir($UBAR_GLOB['BASE_MODEL_PATH'])) {
    getClassPaths($UBAR_GLOB['BASE_MODEL_PATH'], TRUE);
}
// define default timezone
try {
    /**
     * Define default timezone. If not defined, it will throw an exception that is ignored.
     */
    $UBAR_GLOB['TIMEZONE_DEFAULT'] = $props->get('TIMEZONE_DEFAULT');
} catch (Exception $e) {
    // none defined, skip
}
# DEFINE DB SETTINGS
/**
 * Define flag for database usage. You may obviously use database connectivity
 * without this, this merely indicates an intention to use the built in
 * DBManager and errors will be thrown if configuration does not support