public function testAddHandler()
{
$this->if($parser = new script\arguments\parser())->then->object($parser->addHandler($handler = function ($script, $argument, $values) {
}, $arguments = array($argument = '-a')))->isIdenticalTo($parser)->array($parser->getHandlers())->isEqualTo(array($argument => array($handler)))->array($parser->getPriorities())->isEqualTo(array($argument => 0))->object($parser->addHandler($handler, $arguments))->isIdenticalTo($parser)->array($parser->getHandlers())->isEqualTo(array($argument => array($handler, $handler)))->array($parser->getPriorities())->isEqualTo(array($argument => 0))->exception(function () use($parser) {
$parser->addHandler(function () {
}, $argument = array('-b'));
})->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Handler must take three arguments')->exception(function () use($parser) {
$parser->addHandler(function ($script) {
}, array('-b'));
})->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Handler must take three arguments')->exception(function () use($parser) {
$parser->addHandler(function ($script, $argument) {
}, array('-b'));
})->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Handler must take three arguments')->exception(function () use($parser, &$badArgument) {
$parser->addHandler(function ($script, $argument, $values) {
}, array($badArgument = 'b'));
})->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Argument \'' . $badArgument . '\' is invalid')->object($parser->addHandler($otherHandler = function ($script, $argument, $values) {
}, array($otherArgument = '-b'), $priority = rand(-PHP_INT_MAX, PHP_INT_MAX)))->isIdenticalTo($parser)->array($parser->getHandlers())->isEqualTo(array($argument => array($handler, $handler), $otherArgument => array($otherHandler)))->array($parser->getPriorities())->isEqualTo(array($argument => 0, $otherArgument => $priority));
}