require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(20);
$foo = new sfCommandOption('foo', 'f');
$bar = new sfCommandOption('bar', 'b');
$foo1 = new sfCommandOption('fooBis', 'f');
$foo2 = new sfCommandOption('foo', 'p');
// __construct()
$t->diag('__construct()');
$optionSet = new sfCommandOptionSet();
$t->is($optionSet->getOptions(), array(), '__construct() creates a new sfCommandOptionSet object');
$optionSet = new sfCommandOptionSet(array($foo, $bar));
$t->is($optionSet->getOptions(), array('foo' => $foo, 'bar' => $bar), '__construct() takes an array of sfCommandOption objects as its first argument');
// ->setOptions()
$t->diag('->setOptions()');
$optionSet = new sfCommandOptionSet();
$optionSet->setOptions(array($foo));
$t->is($optionSet->getOptions(), array('foo' => $foo), '->setOptions() sets the array of sfCommandOption objects');
$optionSet->setOptions(array($bar));
$t->is($optionSet->getOptions(), array('bar' => $bar), '->setOptions() clears all sfCommandOption objects');
try {
    $optionSet->getOptionForShortcut('f');
    $t->fail('->setOptions() clears all sfCommandOption objects');
} catch (sfCommandException $e) {
    $t->pass('->setOptions() clears all sfCommandOption objects');
}
// ->addOptions()
$t->diag('->addOptions()');
$optionSet = new sfCommandOptionSet();
$optionSet->addOptions(array($foo));
$t->is($optionSet->getOptions(), array('foo' => $foo), '->addOptions() adds an array of sfCommandOption objects');
$optionSet->addOptions(array($bar));