예제 #1
0
$configFile2 = $dataDir . '/parser2.config.yml';
$t = new lime_test(16);
$configuration = new nbConfiguration();
$parser = new nbYamlConfigParser($configuration);
$t->comment('Test get');
$yaml = <<<EOF
key1: value
key2: %key1%
key3_subkey1: %key2%
EOF;
$t->comment('Test parse');
$parser->parse($yaml);
$t->is($configuration->get('key1'), 'value', '->parse() parse a yaml string and set configuration keys');
$t->is($configuration->get('key2'), '%key1%', '->parse() by default does not replace tokens');
$t->is($configuration->get('key3_subkey1'), '%key2%', '->parse() by default does not replace tokens');
$configuration->reset();
$parser->parse($yaml, 'myprefix');
$t->is($configuration->get('myprefix_key1'), 'value', '->parse() can accept a prefix for config keys');
$t->is($configuration->get('myprefix_key2'), '%key1%', '->parse() can accept a prefix for config keys');
$configuration->reset();
$parser->parse($yaml, '', true);
$t->is($configuration->get('key2'), $configuration->get('key1'), '->parse() can replace tokens');
$t->is($configuration->get('key2'), 'value', '->parse() can replace tokens');
$t->is($configuration->get('key3_subkey1'), $configuration->get('key1'), '->parse() can replace tokens');
$t->is($configuration->get('key3_subkey1'), 'value', '->parse() can replace tokens');
$configuration->reset();
$parser->parse($yaml, 'myprefix', true);
$t->is($configuration->get('myprefix_key2'), 'value', '->parse() can replace tokens with prefix');
$t->is($configuration->get('myprefix_key3_subkey1'), 'value', '->parse() can replace tokens with prefix');
$configuration->reset();
$t->comment('Test parseFile');