Ejemplo n.º 1
0
 /**
  * Startup the Agavi core
  *
  * @param      string environment the environment to use for this session.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public static function bootstrap($environment = null)
 {
     // set up our __autoload
     spl_autoload_register(array('AgaviAutoloader', 'loadClass'));
     try {
         if ($environment === null) {
             // no env given? let's read one from core.environment
             $environment = AgaviConfig::get('core.environment');
         } elseif (AgaviConfig::has('core.environment') && AgaviConfig::isReadonly('core.environment')) {
             // env given, but core.environment is read-only? then we must use that instead and ignore the given setting
             $environment = AgaviConfig::get('core.environment');
         }
         if ($environment === null) {
             // still no env? oh man...
             throw new AgaviException('You must supply an environment name to Agavi::bootstrap() or set the name of the default environment to be used in the configuration directive "core.environment".');
         }
         // finally set the env to what we're really using now.
         AgaviConfig::set('core.environment', $environment, true, true);
         AgaviConfig::set('core.debug', false, false);
         if (!AgaviConfig::has('core.app_dir')) {
             throw new AgaviException('Configuration directive "core.app_dir" not defined, terminating...');
         }
         // define a few filesystem paths
         AgaviConfig::set('core.cache_dir', AgaviConfig::get('core.app_dir') . '/cache', false, true);
         AgaviConfig::set('core.config_dir', AgaviConfig::get('core.app_dir') . '/config', false, true);
         AgaviConfig::set('core.system_config_dir', AgaviConfig::get('core.agavi_dir') . '/config/defaults', false, true);
         AgaviConfig::set('core.lib_dir', AgaviConfig::get('core.app_dir') . '/lib', false, true);
         AgaviConfig::set('core.model_dir', AgaviConfig::get('core.app_dir') . '/models', false, true);
         AgaviConfig::set('core.module_dir', AgaviConfig::get('core.app_dir') . '/modules', false, true);
         AgaviConfig::set('core.template_dir', AgaviConfig::get('core.app_dir') . '/templates', false, true);
         AgaviConfig::set('core.cldr_dir', AgaviConfig::get('core.agavi_dir') . '/translation/data', false, true);
         // autoloads first (will trigger the compilation of config_handlers.xml)
         $autoload = AgaviConfig::get('core.config_dir') . '/autoload.xml';
         if (!is_readable($autoload)) {
             $autoload = AgaviConfig::get('core.system_config_dir') . '/autoload.xml';
         }
         AgaviConfigCache::load($autoload);
         // load base settings
         AgaviConfigCache::load(AgaviConfig::get('core.config_dir') . '/settings.xml');
         // clear our cache if the conditions are right
         if (AgaviConfig::get('core.debug')) {
             AgaviToolkit::clearCache();
             // load base settings
             AgaviConfigCache::load(AgaviConfig::get('core.config_dir') . '/settings.xml');
         }
         $compile = AgaviConfig::get('core.config_dir') . '/compile.xml';
         if (!is_readable($compile)) {
             $compile = AgaviConfig::get('core.system_config_dir') . '/compile.xml';
         }
         // required classes for the framework
         AgaviConfigCache::load($compile);
     } catch (Exception $e) {
         AgaviException::render($e);
     }
 }
 /**
  * Flushes the cache for a group
  *
  * @param      array An array of cache groups
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public static function clearCache(array $groups = array())
 {
     foreach ($groups as &$group) {
         $group = base64_encode($group);
     }
     $path = self::CACHE_SUBDIR . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $groups);
     if (is_file(AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . $path . '.cefcache')) {
         AgaviToolkit::clearCache($path . '.cefcache');
     } else {
         AgaviToolkit::clearCache($path);
     }
 }
 private function clearAgaviCache()
 {
     AgaviToolkit::clearCache();
     $this->log('Agavi cache cleared through webinterface', AgaviLogger::INFO);
 }
Ejemplo n.º 4
0
 public function main()
 {
     parent::main();
     AgaviToolkit::clearCache();
 }
Ejemplo n.º 5
0
<?php

$agaviTestSettings = $GLOBALS['AGAVI_TESTING_ISOLATED_TEST_SETTINGS'];
unset($GLOBALS['AGAVI_TESTING_ISOLATED_TEST_SETTINGS']);
if ($agaviTestSettings['bootstrap'] || $agaviTestSettings['clearCache']) {
    require __DIR__ . '/../../testing.php';
}
if ($agaviTestSettings['bootstrap']) {
    // when agavi is not bootstrapped we don't want / need to load the agavi config
    // values from outside the isolation
    AgaviConfig::fromArray($GLOBALS['AGAVI_TESTING_CONFIG']);
}
unset($GLOBALS['AGAVI_TESTING_CONFIG']);
if ($agaviTestSettings['clearCache']) {
    AgaviToolkit::clearCache();
}
$env = null;
if ($agaviTestSettings['environment']) {
    $env = $agaviTestSettings['environment'];
}
if ($agaviTestSettings['bootstrap']) {
    AgaviTesting::bootstrap($env);
}
if ($agaviTestSettings['defaultContext']) {
    AgaviConfig::set('core.default_context', $agaviTestSettings['defaultContext']);
}
if (!defined('AGAVI_TESTING_BOOTSTRAPPED')) {
    // when PHPUnit runs with preserve global state enabled, AGAVI_TESTING_BOOTSTRAPPED will already be defined
    define('AGAVI_TESTING_BOOTSTRAPPED', true);
}
if (AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP) {
 /**
  * Clear all configuration cache files.
  *
  * @author     Sean Kerr <*****@*****.**>
  * @since      0.9.0
  */
 public static function clear()
 {
     AgaviToolkit::clearCache(self::CACHE_SUBDIR);
 }
Ejemplo n.º 7
0
 /**
  * Custom callback for test suite discovery.
  * This is called by PHPUnit in the setup process, right after all command line 
  * arguments have been parsed.
  *
  * @author     Dominik del Bondio <*****@*****.**>
  * @since      1.1.0
  */
 protected function handleCustomTestSuite()
 {
     // ensure the bootstrap script doesn't run and bootstraps agavi another time
     define('AGAVI_TESTING_BOOTSTRAPPED', true);
     AgaviToolkit::clearCache();
     $this->bootstrap($this->arguments['agaviEnvironment']);
     // use the default configuration only if another configuration was not given as command line argument
     $defaultConfigPath = AgaviConfig::get('core.testing_dir') . '/config/phpunit.xml';
     if (empty($this->arguments['configuration']) && is_file($defaultConfigPath)) {
         $this->arguments['configuration'] = $defaultConfigPath;
     }
     $this->arguments['configuration'] = $this->expandConfiguration($this->arguments['configuration']);
     if (count($this->options[1]) > 0) {
         // positional args were given, so the user specified a test or folder on the command line
         return;
     }
     $suites = (require AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml'));
     $masterSuite = new AgaviTestSuite('Master');
     if ($this->arguments['agaviIncludeSuites']) {
         foreach ($this->arguments['agaviIncludeSuites'] as $name) {
             if (empty($suites[$name])) {
                 throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name));
             }
             $masterSuite->addTest(self::createSuite($name, $suites[$name]));
         }
     } else {
         foreach ($suites as $name => $suite) {
             if (!in_array($name, $this->arguments['agaviExcludeSuites'])) {
                 $masterSuite->addTest(self::createSuite($name, $suite));
             }
         }
     }
     $this->arguments['test'] = $masterSuite;
 }