Exemplo n.º 1
0
 public function testHelp()
 {
     $this->if($argumentsParser = new mock\script\arguments\parser())->and($argumentsParser->getMockController()->addHandler = function () {
     })->and($locale = new mock\locale())->and($locale->getMockController()->_ = function ($string) {
         return $string;
     })->and($script = new mock\script($name = uniqid()))->and($script->setArgumentsParser($argumentsParser))->and($script->setLocale($locale))->and($script->getMockController()->writeMessage = $script)->and($script->getMockController()->writeLabels = $script)->then->object($script->help())->isIdenticalTo($script)->mock($script)->call('writeMessage')->never()->mock($script)->call('writeLabels')->never()->if($script->addArgumentHandler(function () {
     }, array('-c', '--c'), $valuesC = '<argumentC>', $helpC = 'help of C argument'))->then->object($script->help())->isIdenticalTo($script)->mock($locale)->call('_')->withArguments('Usage: %s [options]')->once()->mock($script)->call('writeMessage')->withArguments('Usage: ' . $script->getName() . ' [options]' . PHP_EOL)->once()->mock($script)->call('writeLabels')->withArguments(array('-c <argumentC>, --c <argumentC>' => $helpC), 1)->once();
 }
Exemplo n.º 2
0
 public function testHelp()
 {
     $this->if($argumentsParser = new mock\script\arguments\parser())->and($this->calling($argumentsParser)->addHandler = function () {
     })->and($locale = new mock\locale())->and($this->calling($locale)->_ = function ($string) {
         return $string;
     })->and($helpWriter = new mock\writers\std\out())->and($this->calling($helpWriter)->write = function () {
     })->and($script = new mock\script($name = uniqid()))->and($script->setArgumentsParser($argumentsParser))->and($script->setLocale($locale))->and($script->setHelpWriter($helpWriter))->then->object($script->help())->isIdenticalTo($script)->mock($helpWriter)->call('write')->never()->if($script->addArgumentHandler(function () {
     }, array('-c', '--c'), $valuesC = '<argumentC>', $helpC = 'help of C argument'))->then->object($script->help())->isIdenticalTo($script)->mock($locale)->call('_')->withArguments('Usage: %s [options]')->once()->mock($helpWriter)->call('write')->withArguments('Usage: ' . $script->getName() . ' [options]')->once()->withArguments('Available options are:')->once()->withArguments('   -c <argumentC>, --c <argumentC>: help of C argument')->once();
 }