示例#1
0
<?php

require '../loader.php';
class test_config extends registry
{
}
$config = new test_config();
test_assert($config instanceof registry, 'registry');
test_assert(null === $config->test, 'registry get 1');
$config->test = array('title' => 'hello');
if (!test_assert(array('title' => 'hello') === ($test = $config->test), 'registry get 2')) {
    test_print($test);
}
$config->set('simple', 657);
if (!test_assert(657 === ($test = $config->get('simple')), 'registry get 2.1')) {
    test_print($test);
}
$config->clear('test');
test_assert(null === $config->get('test'), 'registry get 3');
test_assert(null === $config->test, 'registry get 4');
// aregistry
$ar = new aregistry();
$ar->set('key', 123);
$ar['sub'] = array('a1' => '-a1-');
test_assert(isset($ar['key']), 'isset1');
test_assert(!empty($ar['key']), 'isset2');
test_assert(isset($ar['sub']['a1']), 'isset3');
unset($ar['key']);
test_assert(!isset($ar['key']), 'isset4');
$ar->set('sub.a2', '44');
test_assert($ar['sub']['a2'] === '44');
示例#2
0
<?php

require '../loader.php';
class test_config extends abs_config
{
}
$config = new test_config();
test_assert($config instanceof abs_config, 'abs_config');
test_assert(null === $config->cfg('test.data.id'), 'cache get 1');
$config->set_cfg_var('test.data.id', array('title' => 'hello'));
if (!test_assert(array('title' => 'hello') === ($test = $config->cfg('test.data.id')), 'cache get 2')) {
    test_print($test);
}
$config->set_cfg_var('simple', 657);
if (!test_assert(657 === ($test = $config->cfg('simple')), 'cache get 2.1')) {
    test_print($test);
}
$config->unset_cfg_var('test.data.id');
test_assert(null === $config->cfg('test.data.id'), 'cache get 3');