Exemplo n.º 1
0
 public function testAddArgumentHandler()
 {
     $this->if($argumentsParser = new mock\script\arguments\parser())->and($argumentsParser->getMockController()->addHandler = function () {
     })->and($script = new mock\script($name = uniqid()))->and($script->setArgumentsParser($argumentsParser))->then->object($script->addArgumentHandler($handlerA = function () {
     }, $argumentsA = array('-a')))->isIdenticalTo($script)->mock($argumentsParser)->call('addHandler')->withArguments($handlerA, $argumentsA)->once()->array($script->getHelp())->isEmpty()->object($script->addArgumentHandler($handlerB = function () {
     }, $argumentsB = array('-b', '--b'), $valuesB = '<argumentB>'))->isIdenticalTo($script)->mock($argumentsParser)->call('addHandler')->withArguments($handlerB, $argumentsB)->once()->array($script->getHelp())->isEmpty()->object($script->addArgumentHandler($handlerC = function () {
     }, $argumentsC = array('-c', '--c'), $valuesC = '<argumentC>', $helpC = 'help of C argument'))->isIdenticalTo($script)->mock($argumentsParser)->call('addHandler')->withArguments($handlerC, $argumentsC)->once()->array($script->getHelp())->isEqualTo(array(array($argumentsC, $valuesC, $helpC)));
 }
Exemplo n.º 2
0
 public function testSetDefaultArgumentHandler()
 {
     $this->if($argumentsParser = new mock\script\arguments\parser())->and($this->calling($argumentsParser)->addHandler = function () {
     })->and($script = new mock\script($name = uniqid()))->and($script->setArgumentsParser($argumentsParser))->then->object($script->setDefaultArgumentHandler($defaultHandler = function ($script, $argument) {
     }))->isIdenticalTo($script)->mock($argumentsParser)->call('setDefaultHandler')->withArguments($defaultHandler)->once()->array($script->getHelp())->isEmpty();
 }