rows; } function schema() { return array('Name' => 1, 'Value' => 1); } } class FakeRequest { public $params = array('named' => array()); } eval('class ConfigsHarness { public $request, $Config, $vars; function set($v) { $this->vars = $v; } function requireSystemView() {} function filterReferencesValue($p) { return false; } function isSecretConfig($c, $n = null) { return false; } function redactSecret($c, $n = null) { return $c; } '.$method.' }'); $failures = 0; function check($n, $got, $want) { global $failures; if ($got === $want) echo "ok - $n\n"; else { $failures++; echo "FAIL - $n (got ".var_export($got, true).", want ".var_export($want, true).")\n"; } } $zm_config = array( 'ZM_WEB_TITLE' => array('Name' => 'ZM_WEB_TITLE', 'Value' => 'From conf.d'), 'ZM_LANG_DEFAULT' => array('Name' => 'ZM_LANG_DEFAULT', 'Value' => 'en_gb'), ); $h = new ConfigsHarness(); $h->request = new FakeRequest(); $h->Config = new FakeConfig(); $h->Config->rows = array( array('Config' => array('Name' => 'ZM_WEB_TITLE', 'Value' => 'From the database')), array('Config' => array('Name' => 'ZM_LANG_DEFAULT', 'Value' => 'en_gb')), ); $h->index(); $byName = array(); foreach ($h->vars['configs'] as $c) $byName[$c['Config']['Name']] = $c['Config']['Value']; check('an option overridden in conf.d is answered with the conf.d value', $byName['ZM_WEB_TITLE'] ?? null, 'From conf.d'); check('an option not overridden keeps its value', $byName['ZM_LANG_DEFAULT'] ?? null, 'en_gb'); check('each option is answered once', count($h->vars['configs']), 2); echo $failures ? "\n$failures failed\n" : "\nall passed\n"; exit($failures ? 1 : 0);