} public static function parseYaml($configFile) { return parent::parseYaml($configFile); } public function mergeConfigValue($keyName, $category) { return parent::mergeConfigValue($keyName, $category); } public function getConfigValue($keyName, $category, $defaultValue = null) { return parent::getConfigValue($keyName, $category, $defaultValue); } } $config = new myConfigHandler(); $config->initialize(); // ->parseYamls() $t->diag('->parseYamls()'); // ->parseYaml() $t->diag('->parseYaml()'); // ->mergeConfigValue() $t->diag('->mergeConfigValue()'); $config->yamlConfig = array('bar' => array('foo' => array('foo' => 'foobar', 'bar' => 'bar')), 'all' => array('foo' => array('foo' => 'fooall', 'barall' => 'barall'))); $values = $config->mergeConfigValue('foo', 'bar'); $t->is($values['foo'], 'foobar', '->mergeConfigValue() merges values for a given key under a given category'); $t->is($values['bar'], 'bar', '->mergeConfigValue() merges values for a given key under a given category'); $t->is($values['barall'], 'barall', '->mergeConfigValue() merges values for a given key under a given category'); // ->getConfigValue() $t->diag('->getConfigValue()'); $config->yamlConfig = array('bar' => array('foo' => 'foobar'), 'all' => array('foo' => 'fooall')); $t->is($config->getConfigValue('foo', 'bar'), 'foobar', '->getConfigValue() returns the value for the key in the given category');
* This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(8); class myConfigHandler extends sfConfigHandler { public function execute($configFiles) { } } $config = new myConfigHandler(); $config->initialize(); // ->initialize() $t->diag('->initialize()'); $config->initialize(array('foo' => 'bar')); $t->is($config->getParameterHolder()->get('foo'), 'bar', '->initialize() takes an array of parameters as its first argument'); // ::replaceConstants() $t->diag('::replaceConstants()'); sfConfig::set('foo', 'bar'); $t->is(sfConfigHandler::replaceConstants('my value with a %foo% constant'), 'my value with a bar constant', '::replaceConstants() replaces constants enclosed in %'); $t->is(sfConfigHandler::replaceConstants('%Y/%m/%d %H:%M'), '%Y/%m/%d %H:%M', '::replaceConstants() does not replace unknown constants'); sfConfig::set('foo', 'bar'); $value = array('foo' => 'my value with a %foo% constant', 'bar' => array('foo' => 'my value with a %foo% constant')); $value = sfConfigHandler::replaceConstants($value); $t->is($value['foo'], 'my value with a bar constant', '::replaceConstants() replaces constants in arrays recursively'); $t->is($value['bar']['foo'], 'my value with a bar constant', '::replaceConstants() replaces constants in arrays recursively'); // ->getParameterHolder()