Ejemplo n.º 1
0
 /**
  * Helper method for loading test configuration from a file.
  *
  * The configuration can be specified by an environment variable. If the
  * variable content is a file name, the configuration is loaded from the
  * file. Otherwise it's assumed to be a json encoded configuration hash. If
  * the environment variable is not set, the method tries to load a conf.php
  * file from the same directory as the test case.
  *
  * @param string $env     An environment variable name.
  * @param string $path    The path to use.
  * @param array $default  Some default values that are merged into the
  *                        configuration if specified as a json hash.
  *
  * @return mixed  The value of the configuration file's $conf variable, or
  *                null.
  */
 public static function getConfig($env, $path = null, $default = array())
 {
     $config = getenv($env);
     if ($config) {
         $json = json_decode($config, true);
         if ($json) {
             return array_replace_recursive($default, $json);
         }
     } else {
         if (!$path) {
             $backtrace = new Horde_Support_Backtrace();
             $caller = $backtrace->getCurrentContext();
             $path = dirname($caller['file']);
         }
         $config = $path . '/conf.php';
     }
     if (file_exists($config)) {
         require $config;
         return $conf;
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * Delegate calls to the schema object.
  *
  * @param  string  $method
  * @param  array   $args
  *
  * @return mixed  TODO
  * @throws BadMethodCallException
  */
 public function __call($method, $args)
 {
     if (!$this->_schema) {
         // Create the database-specific (but not adapter specific) schema
         // object.
         $this->_schema = new $this->_schemaClass($this, array('cache' => $this->_cache, 'logger' => $this->_logger));
         $this->_schemaMethods = array_flip(get_class_methods($this->_schema));
     }
     if (isset($this->_schemaMethods[$method])) {
         return call_user_func_array(array($this->_schema, $method), $args);
     }
     $support = new Horde_Support_Backtrace();
     $context = $support->getContext(1);
     $caller = $context['function'];
     if (isset($context['class'])) {
         $caller = $context['class'] . '::' . $caller;
     }
     throw new BadMethodCallException('Call to undeclared method "' . get_class($this) . '::' . $method . '" from "' . $caller . '"');
 }
Ejemplo n.º 3
0
 public function testNestingLevel()
 {
     $backtrace = new Horde_Support_Backtrace();
     $dbt = debug_backtrace();
     $this->assertEquals(count($dbt), $backtrace->getNestingLevel());
 }