/** * Creates an array of readable configuration items * @return multitype:string mixed */ public function getValuesForDisplay() { $out = array(); $values = AgaviConfig::toArray(); ksort($values); foreach ($values as $k => $v) { if (preg_match('/password|passwd/i', $k)) { $out[] = array('key' => $k, 'value' => self::HIDDEN_VALUE); } else { $out[] = array('key' => $k, 'value' => $this->getValuesDump($v)); } } return $out; }
/** * Startup the Agavi core * * @param string environment the environment to use for this session. * * @author Felix Gilcher <*****@*****.**> * @since 1.0.0 */ public static function bootstrap($environment = null) { if ($environment === null) { // no env given? let's read one from testing.environment $environment = AgaviConfig::get('testing.environment'); } elseif (AgaviConfig::has('testing.environment') && AgaviConfig::isReadonly('testing.environment')) { // env given, but testing.environment is read-only? then we must use that instead and ignore the given setting $environment = AgaviConfig::get('testing.environment'); } if ($environment === null) { // still no env? oh man... throw new Exception('You must supply an environment name to AgaviTesting::bootstrap() or set the name of the default environment to be used for testing in the configuration directive "testing.environment".'); } // finally set the env to what we're really using now. AgaviConfig::set('testing.environment', $environment, true, true); // bootstrap the framework for autoload, config handlers etc. Agavi::bootstrap($environment); ini_set('include_path', get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__))); $GLOBALS['AGAVI_CONFIG'] = AgaviConfig::toArray(); }
/** * Performs custom preparations on the process isolation template. * * @param Text_Template $template * * @author Felix Gilcher <*****@*****.**> * @since 1.0.2 */ protected function prepareTemplate(Text_Template $template) { parent::prepareTemplate($template); // FIXME: workaround for php unit bug (https://github.com/sebastianbergmann/phpunit/pull/1338) $template->setVar(array('dataName' => "'.(" . var_export($this->myDataName, true) . ").'")); // FIXME: if we have full composer autoloading we can remove this // we need to restore the included files even without global state, since otherwise // the agavi test class files would be missing. // We can't write include()s directly since Agavi possibly get's bootstrapped later // in the process (but before the test instance is created) and if we'd load any // files which are being loaded by the bootstrap process chaos would ensue since // the bootstrap process uses plain include()s without _once $fileAutoloader = sprintf(' spl_autoload_register(function($name) { $classMap = %s; if(isset($classMap[$name])) { include($classMap[$name]); } }); ', var_export($this->getDependendClasses(), true)); // these constants are either used by out bootstrap wrapper script // (AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP) or can be used by the user's // bootstrap script (AGAVI_TESTING_IN_SEPERATE_PROCESS) $constants = sprintf(' define("AGAVI_TESTING_IN_SEPERATE_PROCESS", true); define("AGAVI_TESTING_ORIGINAL_PHPUNIT_BOOTSTRAP", %s); ', var_export(isset($GLOBALS["__PHPUNIT_BOOTSTRAP"]) ? $GLOBALS["__PHPUNIT_BOOTSTRAP"] : null, true)); $isolatedTestSettings = array('environment' => $this->getIsolationEnvironment(), 'defaultContext' => $this->getIsolationDefaultContext(), 'clearCache' => $this->getClearCache(), 'bootstrap' => $this->doBootstrap()); $globals = sprintf(' $GLOBALS["AGAVI_TESTING_CONFIG"] = %s; $GLOBALS["AGAVI_TESTING_ISOLATED_TEST_SETTINGS"] = %s; $GLOBALS["__PHPUNIT_BOOTSTRAP"] = %s; ', var_export(AgaviConfig::toArray(), true), var_export($isolatedTestSettings, true), var_export(__DIR__ . '/scripts/IsolatedBootstrap.php', true)); if (!$this->preserveGlobalState) { $template->setVar(array('included_files' => $fileAutoloader, 'constants' => $constants, 'globals' => $globals)); } else { // HACK: oh great, text/template doesn't expose the already set variables, but we need to modify // them instead of overwriting them. So let's use the reflection to the rescue here. $reflected = new ReflectionObject($template); $property = $reflected->getProperty('values'); $property->setAccessible(true); $oldVars = $property->getValue($template); $template->setVar(array('included_files' => $fileAutoloader, 'constants' => $oldVars['constants'] . PHP_EOL . $constants, 'globals' => $oldVars['globals'] . PHP_EOL . $globals)); } }
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()); }
<ul> <?php foreach( $environment['exception_templates'] as $exception ): ?> <li>Context: <?php echo !empty($exception['context'])?$exception['context']:'default'; ?> <?php echo $exception['template']; ?></li> <?php endforeach; ?> </ul> <?php endif; ?> </div> <?php endforeach; ?> </div> <h3>Configuration Directives</h3> <div> <table> <?php $conf = AgaviConfig::toArray(); ksort($conf); foreach($conf as $name => $value): ?> <tr> <td><pre><?php echo htmlspecialchars($name); ?></pre></td> <td><pre><?php echo htmlspecialchars(var_export($value, true)); ?></pre></td> </tr> <?php endforeach; ?> </table> </div> <h3>Agavi</h3> <div> <dl> <dt>Version:</dt> <dd><?php echo AgaviConfig::get('agavi.version'); ?></dd> <dt>Location:</dt>
public function setUp() { $this->conf = AgaviConfig::toArray(); $this->factories = array(); }