public function testFromArrayMergesButDoesNotOverwriteReadonlies() { $data = array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'qux'); AgaviConfig::clear(); AgaviConfig::set('baz', 'lol', true, true); AgaviConfig::fromArray($data); $this->assertEquals(array('baz' => 'lol') + $data, AgaviConfig::toArray()); }
/** * Initialize a module and load its autoload, module config etc. * * @param string The name of the module to initialize. * * @author Felix Gilcher <*****@*****.**> * @since 1.0.0 */ public function initializeModule($moduleName) { $lowerModuleName = strtolower($moduleName); if (null === AgaviConfig::get('modules.' . $lowerModuleName . '.enabled')) { // set some defaults first AgaviConfig::fromArray(array('modules.' . $lowerModuleName . '.agavi.action.path' => '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php', 'modules.' . $lowerModuleName . '.agavi.cache.path' => '%core.module_dir%/${moduleName}/cache/${actionName}.xml', 'modules.' . $lowerModuleName . '.agavi.template.directory' => '%core.module_dir%/${module}/templates', 'modules.' . $lowerModuleName . '.agavi.validate.path' => '%core.module_dir%/${moduleName}/validate/${actionName}.xml', 'modules.' . $lowerModuleName . '.agavi.view.path' => '%core.module_dir%/${moduleName}/views/${viewName}View.class.php', 'modules.' . $lowerModuleName . '.agavi.view.name' => '${actionName}${viewName}')); // include the module configuration // loaded only once due to the way load() (former import()) works if (is_readable(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml')) { include_once AgaviConfigCache::checkConfig(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml'); } else { AgaviConfig::set('modules.' . $lowerModuleName . '.enabled', true); } $moduleAutoload = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/autoload.xml'; if (is_readable($moduleAutoload)) { AgaviConfigCache::load($moduleAutoload); } if (AgaviConfig::get('modules.' . $lowerModuleName . '.enabled')) { $moduleConfigHandlers = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/config_handlers.xml'; if (is_readable($moduleConfigHandlers)) { AgaviConfigCache::addConfigHandlersFile($moduleConfigHandlers); } } } if (!AgaviConfig::get('modules.' . $lowerModuleName . '.enabled')) { throw new AgaviDisabledModuleException(sprintf('The module "%1$s" is disabled.', $moduleName)); } // check for a module config.php $moduleConfig = AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config.php'; if (is_readable($moduleConfig)) { require_once $moduleConfig; } }
<?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) {
public function tearDown() { AgaviConfig::clear(); AgaviConfig::fromArray($this->conf); }