public function end() { $jobCount = $this->runner->getJobCount(); $results = $this->runner->getResults(); $count = array_sum($results); echo !$jobCount ? "No tests found\n" : "\n\n" . $this->buffer . "\n" . ($results[Runner::FAILED] ? Dumper::color('white/red') . 'FAILURES!' : Dumper::color('white/green') . 'OK') . " ({$jobCount} test" . ($jobCount > 1 ? 's' : '') . ", " . ($results[Runner::FAILED] ? $results[Runner::FAILED] . ' failure' . ($results[Runner::FAILED] > 1 ? 's' : '') . ', ' : '') . ($results[Runner::SKIPPED] ? $results[Runner::SKIPPED] . ' skipped, ' : '') . ($jobCount !== $count ? $jobCount - $count . ' not run, ' : '') . sprintf('%0.1f', $this->time + microtime(TRUE)) . ' seconds)' . Dumper::color() . "\n"; $this->buffer = NULL; }
/** @return void */ private function createPhpInterpreter() { $args = ''; if ($this->options['-c']) { $args .= ' -c ' . Helpers::escapeArg($this->options['-c']); } elseif (!$this->options['--info']) { echo "Note: No php.ini is used.\n"; } if (in_array($this->options['-o'], array('tap', 'junit'))) { $args .= ' -d html_errors=off'; } foreach ($this->options['-d'] as $item) { $args .= ' -d ' . Helpers::escapeArg($item); } // Is the executable Zend PHP or HHVM? $proc = @proc_open($this->options['-p'] . ' --version', array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')), $pipes, NULL, NULL, array('bypass_shell' => TRUE)); if ($proc === FALSE) { throw new \Exception('Cannot run PHP interpreter ' . $this->options['-p'] . '. Use -p option.'); } $output = stream_get_contents($pipes[1]); $error = stream_get_contents($pipes[2]); if (proc_close($proc)) { throw new \Exception("Unable to run '{$this->options['-p']}': " . preg_replace('#[\\r\\n ]+#', ' ', $error)); } if (preg_match('#HipHop VM#', $output)) { $this->interpreter = new HhvmPhpInterpreter($this->options['-p'], $args); } else { $this->interpreter = new ZendPhpInterpreter($this->options['-p'], $args); } if ($this->interpreter->getErrorOutput()) { echo Dumper::color('red', 'PHP startup error: ' . $this->interpreter->getErrorOutput()) . "\n"; if ($this->interpreter->isCgi()) { echo "(note that PHP CLI generates better error messages)\n"; } } }
/** @return void */ private function createPhpInterpreter() { $args = $this->options['-C'] ? [] : ['-n']; if ($this->options['-c']) { array_push($args, '-c', $this->options['-c']); } elseif (!$this->options['--info'] && !$this->options['-C']) { echo "Note: No php.ini is used.\n"; } if (in_array($this->options['-o'], ['tap', 'junit'])) { array_push($args, '-d', 'html_errors=off'); } foreach ($this->options['-d'] as $item) { array_push($args, '-d', $item); } $this->interpreter = new PhpInterpreter($this->options['-p'], $args); if ($error = $this->interpreter->getStartupError()) { echo Dumper::color('red', "PHP startup error: {$error}") . "\n"; } }
/** * @param string $destination fully qualified presenter name (module:module:presenter) * @param string $path * @param array $params provided to the presenter usually via URL * @param array $post provided to the presenter via POST * * @return \Nette\Application\Responses\RedirectResponse * @throws \Exception */ protected function checkRedirect($destination, $path = '/', $params = [], $post = []) { /** @var \Nette\Application\Responses\RedirectResponse $response */ $response = $this->check($destination, $params, $post); if (!$this->__testbench_exception) { Assert::same(200, $this->getReturnCode()); Assert::type('Nette\\Application\\Responses\\RedirectResponse', $response); Assert::same(302, $response->getCode()); if ($path) { if (!\Tester\Assert::isMatching("~^https?://test\\.bench{$path}(?(?=\\?).+)\$~", $response->getUrl())) { $path = Dumper::color('yellow') . Dumper::toLine($path) . Dumper::color('white'); $url = Dumper::color('yellow') . Dumper::toLine($response->getUrl()) . Dumper::color('white'); $originalUrl = new \Nette\Http\Url($response->getUrl()); Assert::fail(str_repeat(' ', strlen($originalUrl->getHostUrl()) - 13) . "path {$path} doesn't match\n{$url}\nafter redirect"); } } } return $response; }