예제 #1
0
try {
    $checker->checkConfigFile($templateFileNotExists, $configFileOk);
    $t->fail('No template file to check exists');
} catch (Exception $e) {
    $t->pass('No template file to check exists');
}
try {
    $checker->checkConfigFile($templateFile, $dirNotExists);
    $t->fail('No directory exists (and it should be)');
} catch (Exception $e) {
    $t->pass('No directory exists (and it should be)');
}
try {
    $checker->checkConfigFile($templateFile, $fileNotExists);
    $t->fail('No file exists (and it should be)');
} catch (Exception $e) {
    $t->pass('No file exists (and it should be)');
}
$t->comment(' 5. Check whole configuration');
nbConfig::set('app_required_field', 'value');
try {
    $checker->check($templateFile, nbConfig::getConfiguration());
    $t->fail('Whole configuration without required fields not checked successfully');
} catch (Exception $e) {
    $t->pass('Whole configuration without required fields not checked successfully');
}
$t->ok($checker->hasErrors(), 'Configuration has errors');
$t->is(count($checker->getErrors()), 1, 'Configuration has 1 error');
nbConfig::set('app_required_child_field', 'value');
$checker->check($templateFile, nbConfig::getConfiguration());
$t->ok(!$checker->hasErrors(), 'Configuration has no errors');