public function testGetExitCode() { $this->if($php = new testedClass(null, $adapter = new atoum\test\adapter()))->then->variable($php->getExitCode())->isNull()->if($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->fclose = null)->and($adapter->stream_set_blocking = null)->and($adapter->stream_get_contents = null)->and($adapter->proc_close = null)->and($adapter->proc_get_status[1] = array('running' => true))->and($adapter->proc_get_status[2] = array('running' => false, 'exitcode' => $exitCode = rand(0, PHP_INT_MAX)))->and($php->run())->then->variable($php->getExitCode())->isEqualTo($exitCode); }
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; }