コード例 #1
0
ファイル: script.php プロジェクト: ronan-gloo/atoum
 public function testPrompt()
 {
     if (defined('STDIN') === false) {
         define('STDIN', rand(1, PHP_INT_MAX));
     }
     $this->if($adapter = new atoum\test\adapter())->and($adapter->fgets = $input = uniqid())->and($script = new mock\script(uniqid(), $adapter))->and($stdOut = new mock\writers\std\out())->and($stdOut->getMockCOntroller()->write = function () {
     })->and($script->setOutputWriter($stdOut))->then->string($script->prompt($message = uniqid()))->isEqualTo($input)->mock($stdOut)->call('write')->withIdenticalArguments($message)->once()->adapter($adapter)->call('fgets')->withArguments(STDIN)->once()->string($script->prompt(($message = ' ' . $message) . "\t\n"))->isEqualTo($input)->mock($stdOut)->call('write')->withIdenticalArguments($message)->once()->adapter($adapter)->call('fgets')->withArguments(STDIN)->exactly(2)->if($adapter->fgets = ' ' . ($input = uniqid()) . "\t")->then->string($script->prompt($message = uniqid()))->isEqualTo($input)->mock($stdOut)->call('write')->withIdenticalArguments($message)->once()->adapter($adapter)->call('fgets')->withArguments(STDIN)->exactly(3);
 }
コード例 #2
0
ファイル: script.php プロジェクト: xihewang/atoum
 public function testPrompt()
 {
     $this->if($prompt = new mock\script\prompt())->and($this->calling($prompt)->ask = $answer = uniqid())->and($script = new mock\script(uniqid()))->and($script->setPrompt($prompt))->then->string($script->prompt($message = uniqid()))->isEqualTo($answer)->mock($prompt)->call('ask')->withIdenticalArguments($message)->once()->string($script->prompt(($message = ' ' . $message) . "\t\n"))->isEqualTo($answer)->mock($prompt)->call('ask')->withIdenticalArguments($message)->once()->if($this->calling($prompt)->ask = ' ' . ($answer = uniqid()) . "\t")->then->string($script->prompt($message = uniqid()))->isEqualTo($answer)->mock($prompt)->call('ask')->withIdenticalArguments($message)->once();
 }