예제 #1
0
 public function testRun()
 {
     $this->if($php = new testedClass($phpPath = uniqid(), $adapter = new atoum\test\adapter()))->and($adapter->proc_open = false)->then->exception(function () use($php, &$code) {
         $php->run($code = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\cli\\command\\exception')->hasMessage('Unable to run \'' . $php . '\'')->adapter($adapter)->call('proc_open')->withArguments((string) $php, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), array())->once()->if($php = new testedClass($phpPath = uniqid(), $adapter))->and($code = uniqid())->and($adapter->proc_open = function ($command, $descriptors, &$streams) use(&$phpResource, &$stdin, &$stdout, &$stderr) {
         $streams = array($stdin = uniqid(), $stdout = uniqid(), $stderr = uniqid);
         return $phpResource = uniqid();
     })->and($adapter->fwrite = strlen($code))->and($adapter->fclose = null)->and($adapter->stream_set_blocking = null)->then->object($php->run($code))->isIdenticalTo($php)->adapter($adapter)->call('proc_open')->withArguments((string) $php, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), array())->once()->call('fwrite')->withArguments($stdin, $code, strlen($code))->once()->call('fclose')->withArguments($stdin)->once()->call('stream_set_blocking')->withArguments($stdout)->once()->call('stream_set_blocking')->withArguments($stderr)->once()->if($php = new testedClass($phpPath = uniqid(), $adapter))->and($adapter->resetCalls())->and($adapter->fwrite[1] = 4)->and($adapter->fwrite[2] = strlen($code) - 4)->then->object($php->run($code))->isIdenticalTo($php)->adapter($adapter)->call('proc_open')->withArguments((string) $php, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), array())->once()->call('fwrite')->withArguments($stdin, $code, strlen($code))->once()->call('fwrite')->withArguments($stdin, substr($code, 4), strlen($code) - 4)->once()->call('fclose')->withArguments($stdin)->once()->call('stream_set_blocking')->withArguments($stdout)->once()->call('stream_set_blocking')->withArguments($stderr)->once()->if($php = new testedClass($phpPath = uniqid(), $adapter))->and($php->addOption('firstOption'))->then->object($php->run($code))->isIdenticalTo($php)->adapter($adapter)->call('proc_open')->withArguments((string) $php, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), array())->once()->if($php = new testedClass($phpPath = uniqid(), $adapter))->and($php->addOption('firstOption'))->and($php->addOption('secondOption', 'secondOptionValue'))->then->object($php->run($code))->isIdenticalTo($php)->adapter($adapter)->call('proc_open')->withArguments((string) $php, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), array())->once()->if($php = new testedClass($phpPath = uniqid(), $adapter))->and($php->addArgument($argument1 = uniqid()))->and($php->addArgument($argument2 = uniqid()))->then->object($php->run($code))->isIdenticalTo($php)->adapter($adapter)->call('proc_open')->withArguments((string) $php, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), array())->once();
 }
예제 #2
0
파일: runner.php 프로젝트: eroluysal/atoum
 protected function loop()
 {
     $php = new php();
     $php->addOption('-f', $_SERVER['argv'][0])->addArgument('--disable-loop-mode');
     if ($this->cli->isTerminal() === true) {
         $php->addArgument('--force-terminal');
     }
     $addScoreFile = false;
     foreach ($this->argumentsParser->getValues() as $argument => $values) {
         switch ($argument) {
             case '-l':
             case '--loop':
             case '--disable-loop-mode':
                 break;
             case '-sf':
             case '--score-file':
                 $addScoreFile = true;
                 break;
             default:
                 if ($this->argumentsParser->argumentHasHandler($argument) === false) {
                     $php->addArgument('-f', $argument);
                 } else {
                     $php->addArgument($argument, join(' ', $values));
                 }
         }
     }
     if ($this->scoreFile === null) {
         $this->scoreFile = sys_get_temp_dir() . '/atoum.score';
         @unlink($this->scoreFile);
         $addScoreFile = true;
     }
     if ($addScoreFile === true) {
         $php->addArgument('--score-file', $this->scoreFile);
     }
     while ($this->canRun() === true) {
         passthru((string) $php);
         if ($this->loop === false || $this->runAgain() === false) {
             $this->stopRun();
         }
     }
     return $this;
 }