Esempio n. 1
0
// ->hasOption()
$t->comment('nbOptionSetTest - Test has option');
$set = new nbOptionSet(array($foo));
$t->is($set->hasOption('foo'), true, '->hasOption() returns true if an nbOption exists for the given name');
$t->is($set->hasOption('f'), true, '->hasOption() returns true if an nbOption exists for the given shortcut');
$t->is($set->hasOption('bar'), false, '->hasOption() returns false if an nbOption does not exists for the given name');
// ->countRequired()
$t->comment('nbOptionSetTest - Test option required count');
$set = new nbOptionSet(array($requiredOption));
$t->is($set->countRequired(), 1, '->countRequired() returns the number of required options');
$set->addOption($foo);
$t->is($set->countRequired(), 1, '->countRequired() returns the number of required options');
// ->count()
$t->comment('nbOptionSetTest - Test get option count');
$set = new nbOptionSet();
$set->addOption($foo);
$t->is($set->count(), 1, '->count() returns the number of options');
$set->addOption($bar);
$t->is($set->count(), 2, '->count() returns the number of options');
// ->getDefaultValues()
$t->comment('nbOptionSetTest - Test get values');
$set = new nbOptionSet();
$set->addOptions(array(new nbOption('foo', '', nbOption::PARAMETER_REQUIRED), new nbOption('foo1', '', nbOption::PARAMETER_OPTIONAL), new nbOption('foo2', '', nbOption::PARAMETER_OPTIONAL, '', 'default'), new nbOption('foo3', '', nbOption::PARAMETER_OPTIONAL | nbOption::IS_ARRAY)));
$t->is($set->getDefaultValues(), array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), '->getDefaultValues() returns the default values for each option');
$set = new nbOptionSet();
$set->addOptions(array(new nbOption('foo4', '', nbOption::PARAMETER_OPTIONAL | nbOption::IS_ARRAY, '', array(1, 2))));
$t->is($set->getDefaultValues(), array('foo4' => array(1, 2)), '->getDefaultValues() return the default values for each option');
$t->comment('nbOptionSet - Test shortcuts');
$set = new nbOptionSet(array(new nbOption('foo', 'f'), new nbOption('bar', 'b'), new nbOption('bas', '')));
$t->is($set->hasShortcut('f'), true, '->hasShortcut() returns true for shortcut "f"');
$t->is($set->hasShortcut('u'), false, '->hasShortcut() returns false for shortcut "u"');