本文整理汇总了PHP中PHP_CodeCoverage_Report_HTML类的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeCoverage_Report_HTML类的具体用法?PHP PHP_CodeCoverage_Report_HTML怎么用?PHP PHP_CodeCoverage_Report_HTML使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHP_CodeCoverage_Report_HTML类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stop
/**
* Stop to analysis the code coverage of the current request
* If STOP_COVERAGE_ANALISYS is set in GET parameters, build the code coverage report
* @global PHP_CodeCoverage $coverage
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
function stop()
{
global $coverage;
if (!isset($_GET["STOP_COVERAGE_ANALISYS"])) {
$coverage->stop();
$s = serialize($coverage);
$token = uniqid();
file_put_contents(FCPATH . 'local/temp/coverage/requests/' . $token, $s);
} else {
$files = glob(FCPATH . 'local/temp/coverage/requests/*');
foreach ($files as $file) {
$s = file_get_contents($file);
$data = unserialize($s);
$coverage->merge($data);
}
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($coverage, FCPATH . 'local/temp/coverage/code-coverage-report');
//Delete all files that were used to trace the requests
$files = glob(FCPATH . 'local/temp/coverage/requests/*');
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
}
}
示例2: run
public function run($input, $output = 'real-coverage-html')
{
$report = unserialize(file_get_contents($input));
$reader = new ParsingCoverageReader();
$classes = $reader->parseReport($report);
$mutator = new Mutator();
$testRunner = new PHPUnitRunner(new MultirunTestCommand(), array('tests', 'tests'));
$writer = new RealCoverageModifier($report);
$proxyFactory = new ProxyFactory($classes);
$autoloader = new ProxyAutoloader($proxyFactory);
$autoloader->register();
$classCounter = 0;
/** @var ClassMetadata $class */
foreach ($classes as $class) {
if (!$class->isCovered()) {
continue;
}
echo "\n" . (int) (++$classCounter * 100 / count($classes)) . "%: Processing " . $class->getName() . "\n";
$this->calculateRealCoverage($class, $proxyFactory, $testRunner, $mutator);
$writer->write($class);
}
$autoloader->unregister();
echo "\n\nWriting coverage report to " . $output . "\n";
$htmlWriter = new \PHP_CodeCoverage_Report_HTML();
$htmlWriter->process($report, $output);
}
示例3: testForClassWithAnonymousFunction
/**
* @covers PHP_CodeCoverage_Report_HTML
*/
public function testForClassWithAnonymousFunction()
{
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
$report = new PHP_CodeCoverage_Report_HTML();
$report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
}
示例4: aferRunTests
/**
* Overwrites aferRunTests. Creates coverage report and clover report
* if required.
*/
protected function aferRunTests()
{
if ($this->getCoverageStatus()) {
$coverage = $this->coverage;
$coverage->stop();
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($coverage, ASSETS_PATH . '/code-coverage-report');
}
}
示例5: createCodeCoverageReport
/**
* Creates code coverage report.
*
* @param \PHP_CodeCoverage $coverage Code coverage collector.
* @return void
*/
public function createCodeCoverageReport(\PHP_CodeCoverage $coverage = null)
{
if (!isset($coverage)) {
echo '<h3>Code coverage analysis unavailable</h3><p>To enable code coverage, the xdebug php module must be installed and enabled.</p>';
return;
}
$writer = new \PHP_CodeCoverage_Report_HTML();
$writer->process($coverage, FULL_PATH . '/test/runtime/coverage');
echo '<a href="runtime/coverage" target="_blank">Code coverage report</a>';
}
示例6: _stopCoverage
protected function _stopCoverage()
{
if (!$this->doCoverage) {
return;
}
$writer = new PHP_CodeCoverage_Report_Clover();
$writer->process($this->_coverage, ROOT . DS . 'build' . DS . 'logs' . DS . 'clover.xml');
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($this->_coverage, ROOT . DS . 'build' . DS . 'logs' . DS . 'clover' . DS);
}
示例7: it_should_output_html_report
function it_should_output_html_report(\PHP_CodeCoverage $coverage, \PHP_CodeCoverage_Report_HTML $html, SuiteEvent $event, IO $io)
{
$reports = array('html' => $html);
$this->beConstructedWith($coverage, $reports);
$this->setOptions(array('format' => 'html', 'output' => array('html' => 'coverage')));
$io->isVerbose()->willReturn(false);
$this->setIO($io);
$io->writeln(Argument::any())->shouldNotBeCalled();
$html->process($coverage, 'coverage')->willReturn('report');
$this->afterSuite($event);
}
示例8: printHtml
protected function printHtml()
{
$writer = new \PHP_CodeCoverage_Report_HTML(
$this->settings['low_limit'],
$this->settings['high_limit'],
sprintf(
', <a href="http://codeception.com">Codeception</a> and <a href="http://phpunit.de/">PHPUnit %s</a>',
\PHPUnit_Runner_Version::id()
)
);
$writer->process(self::$coverage, $this->absolutePath($this->options['coverage-html']));
}
示例9: __c3_build_html_report
function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
{
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($codeCoverage, $path . 'html');
if (file_exists($path . '.tar')) {
unlink($path . '.tar');
}
$phar = new PharData($path . '.tar');
$phar->setSignatureAlgorithm(Phar::SHA1);
$files = $phar->buildFromDirectory($path . 'html');
array_map('unlink', $files);
if (in_array('GZ', Phar::getSupportedCompression())) {
if (file_exists($path . '.tar.gz')) {
unlink($path . '.tar.gz');
}
$phar->compress(\Phar::GZ);
// close the file so that we can rename it
unset($phar);
unlink($path . '.tar');
rename($path . '.tar.gz', $path . '.tar');
}
return $path . '.tar';
}
示例10: doRun
//.........这里部分代码省略.........
}
$result->addListener($this->printer);
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger());
}
if (isset($arguments['testdoxHTMLFile'])) {
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
}
if (isset($arguments['testdoxTextFile'])) {
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
}
$codeCoverageReports = 0;
if (extension_loaded('xdebug')) {
if (isset($arguments['coverageClover'])) {
$codeCoverageReports++;
}
if (isset($arguments['reportDirectory'])) {
$codeCoverageReports++;
}
if (isset($arguments['coveragePHP'])) {
$codeCoverageReports++;
}
if (isset($arguments['coverageText'])) {
$codeCoverageReports++;
}
}
if ($codeCoverageReports > 0) {
$codeCoverage = new PHP_CodeCoverage(null, $this->codeCoverageFilter);
$codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
$codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
if (isset($arguments['forceCoversAnnotation'])) {
$codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
}
if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
$codeCoverage->setMapTestClassNameToCoveredClassName($arguments['mapTestClassNameToCoveredClassName']);
}
$result->setCodeCoverage($codeCoverage);
}
if ($codeCoverageReports > 1) {
if (isset($arguments['cacheTokens'])) {
$codeCoverage->setCacheTokens($arguments['cacheTokens']);
}
}
if (isset($arguments['jsonLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
}
if (isset($arguments['tapLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
}
if (isset($arguments['junitLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
}
if ($arguments['strict']) {
$result->strictMode(true);
$result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
$result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
$result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
}
$suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
unset($suite);
$result->flushListeners();
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$this->printer->printResult($result);
}
if (isset($codeCoverage)) {
if (isset($arguments['coverageClover'])) {
$this->printer->write("\nGenerating code coverage report in Clover XML format ...");
$writer = new PHP_CodeCoverage_Report_Clover();
$writer->process($codeCoverage, $arguments['coverageClover']);
$this->printer->write(" done\n");
unset($writer);
}
if (isset($arguments['reportDirectory'])) {
$this->printer->write("\nGenerating code coverage report in HTML format ...");
$writer = new PHP_CodeCoverage_Report_HTML($arguments['reportCharset'], $arguments['reportHighlight'], $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], sprintf(' and <a href="http://phpunit.de/">PHPUnit %s</a>', PHPUnit_Runner_Version::id()));
$writer->process($codeCoverage, $arguments['reportDirectory']);
$this->printer->write(" done\n");
unset($writer);
}
if (isset($arguments['coveragePHP'])) {
$this->printer->write("\nGenerating code coverage report in PHP format ...");
$writer = new PHP_CodeCoverage_Report_PHP();
$writer->process($codeCoverage, $arguments['coveragePHP']);
$this->printer->write(" done\n");
unset($writer);
}
if (isset($arguments['coverageText'])) {
if ($arguments['coverageText'] == 'php://stdout') {
$outputStream = $this->printer;
$colors = (bool) $arguments['colors'];
} else {
$outputStream = new PHPUnit_Util_Printer($arguments['coverageText']);
$colors = false;
}
$writer = new PHP_CodeCoverage_Report_Text($outputStream, $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], $arguments['coverageTextShowUncoveredFiles']);
$writer->process($codeCoverage, $colors);
}
}
return $result;
}
示例11: writeCoverageHtml
/**
* This method generates a html coverage report.
*
* @param PHP_CodeCoverage $coverage The raw coverage data.
*
* @return void
*/
protected function writeCoverageHtml(PHP_CodeCoverage $coverage)
{
if ($this->coverageHtml) {
$this->writeLine('Writing change coverage report, this may take a moment.');
$this->writeLine();
$html = new PHP_CodeCoverage_Report_HTML('Coverage Report for files modified since ' . date('Y/m/d', $this->modifiedSince), 'UTF-8', false, false, 35, 70, ' post processed by PHP_ChangeCoverage');
$html->process($coverage, $this->coverageHtml);
}
}
示例12: doRun
//.........这里部分代码省略.........
$suite = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
}
$result = $this->createTestResult();
if (!$arguments['convertErrorsToExceptions']) {
$result->convertErrorsToExceptions(FALSE);
}
if (!$arguments['convertNoticesToExceptions']) {
PHPUnit_Framework_Error_Notice::$enabled = FALSE;
}
if (!$arguments['convertWarningsToExceptions']) {
PHPUnit_Framework_Error_Warning::$enabled = FALSE;
}
if ($arguments['stopOnError']) {
$result->stopOnError(TRUE);
}
if ($arguments['stopOnFailure']) {
$result->stopOnFailure(TRUE);
}
if ($arguments['stopOnIncomplete']) {
$result->stopOnIncomplete(TRUE);
}
if ($arguments['stopOnSkipped']) {
$result->stopOnSkipped(TRUE);
}
if ($this->printer === NULL) {
if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
$this->printer = $arguments['printer'];
} else {
$this->printer = new PHPUnit_TextUI_ResultPrinter(NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
}
}
if (!$this->printer instanceof PHPUnit_Util_Log_TAP && !self::$versionStringPrinted) {
$this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
if (isset($arguments['configuration'])) {
$this->printer->write(sprintf("Configuration read from %s\n\n", $arguments['configuration']->getFilename()));
}
}
foreach ($arguments['listeners'] as $listener) {
$result->addListener($listener);
}
$result->addListener($this->printer);
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger());
}
if (isset($arguments['testdoxHTMLFile'])) {
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
}
if (isset($arguments['testdoxTextFile'])) {
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
}
if ((isset($arguments['coverageClover']) || isset($arguments['reportDirectory'])) && extension_loaded('xdebug')) {
$result->setCodeCoverage($this->codeCoverage);
}
if (isset($arguments['logDbus'])) {
$result->addListener(new PHPUnit_Util_Log_DBUS());
}
if (isset($arguments['jsonLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
}
if (isset($arguments['tapLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
}
if (isset($arguments['junitLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
}
if ($arguments['strict']) {
$result->strictMode(TRUE);
}
$suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
unset($suite);
$result->flushListeners();
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$this->printer->printResult($result);
}
if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
if (isset($arguments['coverageClover'])) {
$this->printer->write("\nWriting code coverage data to XML file, this may take " . 'a moment.');
$writer = new PHP_CodeCoverage_Report_Clover($arguments['cacheTokens']);
$writer->process($this->codeCoverage, $arguments['coverageClover']);
$this->printer->write("\n");
unset($writer);
}
if (isset($arguments['reportDirectory'])) {
$this->printer->write("\nGenerating code coverage report, this may take a moment.");
$title = '';
if (isset($arguments['configuration'])) {
$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
if (isset($loggingConfiguration['title'])) {
$title = $loggingConfiguration['title'];
}
}
$writer = new PHP_CodeCoverage_Report_HTML(array('title' => $title, 'cacheTokens' => $arguments['cacheTokens'], 'charset' => $arguments['reportCharset'], 'yui' => $arguments['reportYUI'], 'highlight' => $arguments['reportHighlight'], 'lowUpperBound' => $arguments['reportLowUpperBound'], 'highLowerBound' => $arguments['reportHighLowerBound'], 'generator' => ' and PHPUnit ' . PHPUnit_Runner_Version::id()));
$writer->process($this->codeCoverage, $arguments['reportDirectory']);
$this->printer->write("\n");
unset($writer);
}
}
$this->pause($arguments['wait']);
return $result;
}
示例13: sizeof
echo 'Tests:', $count . PHP_EOL;
echo 'Broken:', sizeof($brokenTests) . PHP_EOL;
if (isset($opt['v']) || isset($opt['verbose'])) {
foreach ($brokenTests as $caseOut => $test) {
file_put_contents($caseOut . '-got', $test);
passthru('diff -u ' . $caseOut . ' ' . $caseOut . '-got 2>&1');
unlink($caseOut . '-got');
}
}
echo 'Took ', microtime(true) - $start;
if (!is_null($bogomips)) {
echo ' at ', $bogomips, ' bogomips';
}
echo PHP_EOL;
if ($isCoverage && !$isCoveralls) {
$writer = new PHP_CodeCoverage_Report_HTML();
$writer->process($coverage, './cover/');
}
if ($isCoveralls) {
$writer = new PHP_CodeCoverage_Report_Clover();
$writer->process($coverage, './clover.xml');
}
if (sizeof($brokenTests) > 0) {
echo 'run test.php -v to see the error diffs', PHP_EOL;
exit(255);
}
exit(0);
function getToken($token)
{
if (is_string($token)) {
return [$token, $token];
示例14: main
/**
* Main method.
*/
public function main()
{
$input = new \ezcConsoleInput();
$input->registerOption(new \ezcConsoleOption('', 'clover', \ezcConsoleInput::TYPE_STRING));
$input->registerOption(new \ezcConsoleOption('', 'configuration', \ezcConsoleInput::TYPE_STRING));
$input->registerOption(new \ezcConsoleOption('', 'html', \ezcConsoleInput::TYPE_STRING));
$input->registerOption(new \ezcConsoleOption('', 'php', \ezcConsoleInput::TYPE_STRING));
$input->registerOption(new \ezcConsoleOption('', 'text', \ezcConsoleInput::TYPE_STRING));
$input->registerOption(new \ezcConsoleOption('', 'blacklist', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
$input->registerOption(new \ezcConsoleOption('', 'whitelist', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
$input->registerOption(new \ezcConsoleOption('', 'merge', \ezcConsoleInput::TYPE_NONE, FALSE));
$input->registerOption(new \ezcConsoleOption('', 'add-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE));
$input->registerOption(new \ezcConsoleOption('', 'process-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE));
$input->registerOption(new \ezcConsoleOption('h', 'help', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
$input->registerOption(new \ezcConsoleOption('v', 'version', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
try {
$input->process();
} catch (ezcConsoleOptionException $e) {
print $e->getMessage() . "\n";
exit(1);
}
if ($input->getOption('help')->value) {
$this->showHelp();
exit(0);
} else {
if ($input->getOption('version')->value) {
$this->printVersionString();
exit(0);
}
}
$arguments = $input->getArguments();
$clover = $input->getOption('clover')->value;
$configuration = $input->getOption('configuration')->value;
$html = $input->getOption('html')->value;
$php = $input->getOption('php')->value;
$text = $input->getOption('text')->value;
$blacklist = $input->getOption('blacklist')->value;
$whitelist = $input->getOption('whitelist')->value;
$addUncovered = $input->getOption('add-uncovered')->value;
$processUncovered = $input->getOption('process-uncovered')->value;
$merge = $input->getOption('merge')->value;
$coverage = new \PHP_CodeCoverage();
$filter = $coverage->filter();
if ($configuration) {
$this->handleConfiguration($configuration, $coverage);
}
if (count($arguments) == 1) {
$this->printVersionString();
if (empty($whitelist)) {
$c = new \ReflectionClass('ezcBase');
$filter->addDirectoryToBlacklist(dirname($c->getFileName()));
$c = new \ReflectionClass('ezcConsoleInput');
$filter->addDirectoryToBlacklist(dirname($c->getFileName()));
foreach ($blacklist as $item) {
if (is_dir($item)) {
$filter->addDirectoryToBlacklist($item);
} else {
if (is_file($item)) {
$filter->addFileToBlacklist($item);
}
}
}
} else {
$coverage->setAddUncoveredFilesFromWhitelist($addUncovered);
$coverage->setProcessUncoveredFilesFromWhitelist($processUncovered);
foreach ($whitelist as $item) {
if (is_dir($item)) {
$filter->addDirectoryToWhitelist($item);
} else {
if (is_file($item)) {
$filter->addFileToWhitelist($item);
}
}
}
}
if (!$merge) {
$coverage->start('phpcov');
require $arguments[0];
$coverage->stop();
} else {
$facade = new \File_Iterator_Facade();
$files = $facade->getFilesAsArray($arguments[0], '.cov');
foreach ($files as $file) {
$coverage->merge(unserialize(file_get_contents($file)));
}
}
if ($clover) {
print "\nGenerating code coverage report in Clover XML format ...";
$writer = new \PHP_CodeCoverage_Report_Clover();
$writer->process($coverage, $clover);
print " done\n";
}
if ($html) {
print "\nGenerating code coverage report in HTML format ...";
$writer = new \PHP_CodeCoverage_Report_HTML();
$writer->process($coverage, $html);
print " done\n";
//.........这里部分代码省略.........
示例15: logCoverage
/**
* Write coverage to file if requested
*/
private function logCoverage()
{
if (!$this->hasCoverage()) {
return;
}
$filteredOptions = $this->options->filtered;
if (isset($filteredOptions['coverage-clover'])) {
$clover = new \PHP_CodeCoverage_Report_Clover();
$clover->process($this->getCoverage()->getCoverage(), $filteredOptions['coverage-clover']);
}
if (isset($filteredOptions['coverage-html'])) {
$html = new \PHP_CodeCoverage_Report_HTML();
$html->process($this->getCoverage()->getCoverage(), $filteredOptions['coverage-html']);
}
$php = new \PHP_CodeCoverage_Report_PHP();
$php->process($this->getCoverage()->getCoverage(), $filteredOptions['coverage-php']);
}