mageekguy\atoum\test\engines\concurrent::getScore PHP Method

getScore() public method

public getScore ( )
    public function getScore()
    {
        $score = null;
        if ($this->test !== null && $this->php->isRunning() === false) {
            $stdOut = $this->php->getStdout();
            $score = @unserialize($stdOut);
            if ($score instanceof atoum\score === false) {
                $score = call_user_func($this->scoreFactory)->addUncompletedMethod($this->test->getPath(), $this->test->getClass(), $this->method, $this->php->getExitCode(), $this->php->getStdOut());
            }
            $stdErr = $this->php->getStderr();
            if ($stdErr !== '') {
                if (preg_match_all('/([^:]+): (.+) in (.+) on line ([0-9]+)/', trim($stdErr), $errors, PREG_SET_ORDER) === 0) {
                    $score->addError($this->test->getPath(), $this->test->getClass(), $this->method, null, 'UNKNOWN', $stdErr);
                } else {
                    foreach ($errors as $error) {
                        $score->addError($this->test->getPath(), $this->test->getClass(), $this->method, null, $error[1], $error[2], $error[3], $error[4]);
                    }
                }
            }
        }
        return $score;
    }

Usage Example

Exemplo n.º 1
0
 public function testGetScore()
 {
     $this->if($engine = new engines\concurrent())->then->variable($engine->getScore())->isNull()->if($engine = new engines\concurrent())->and($engine->setAdapter($adapter = new atoum\test\adapter()))->and($engine->run($test = new \mock\mageekguy\atoum\test()))->then->variable($engine->getScore())->isNull()->if($test->getMockController()->getCurrentMethod = $method = uniqid())->and($test->getMockController()->getPath = $testPath = uniqid())->and($test->getMockController()->getPhpPath = $phpPath = uniqid())->and($test->getMockController()->codeCoverageIsEnabled = false)->and($test->getMockController()->getBootstrapFile = null)->and($adapter->proc_open = function ($command, array $descriptors, array &$pipes) use(&$resource, &$stdIn, &$stdOut, &$stdErr) {
         $pipes = array($stdIn = uniqid(), $stdOut = uniqid(), $stdErr = uniqid());
         return $resource = uniqid();
     })->and($adapter->proc_close = function () {
     })->and($adapter->proc_get_status = array('running' => true))->and($adapter->fwrite = function () {
     })->and($adapter->fclose = function () {
     })->and($adapter->stream_set_blocking = function () {
     })->and($adapter->stream_get_contents = $output = uniqid())->and($engine->run($test))->then->variable($engine->getScore())->isNull()->if($adapter->proc_get_status = array('running' => false, 'exitcode' => $exitCode = rand(1, PHP_INT_MAX)))->then->object($score = $engine->getScore())->isInstanceOf('mageekguy\\atoum\\score')->array($score->getUncompletedMethods())->isEqualTo(array(array('class' => get_class($test), 'method' => $method, 'exitCode' => $exitCode, 'output' => $output . $output)))->if($adapter->stream_get_contents = serialize($score))->and($engine->run($test))->then->object($score = $engine->getScore())->isEqualTo($score);
 }
All Usage Examples Of mageekguy\atoum\test\engines\concurrent::getScore