Skip to content

Instantly share code, notes, and snippets.

@twogood
Created December 20, 2012 11:54
Show Gist options
  • Save twogood/4344878 to your computer and use it in GitHub Desktop.
Save twogood/4344878 to your computer and use it in GitHub Desktop.
<VirtualHost *:80>
# ....
php_value auto_prepend_file /etc/apache2/local/coverage-start.php
php_value auto_append_file /etc/apache2/local/coverage-stop.php
# ....
</VirtualHost>
<?php
if (isset($_GET['coverage'])) {
setcookie('coverage', $_GET['coverage']);
}
if ((isset($_GET['coverage']) && $_GET['coverage'] == '1')
|| (isset($_COOKIE['coverage']) && $_COOKIE['coverage'] == '1')){
require 'PHP/CodeCoverage/Autoload.php';
$_____coverage = new PHP_CodeCoverage;
$_____coverage->start('apache');
}
<?php
if (isset($_____coverage)){
$_____coverage->stop();
$writer = new PHP_CodeCoverage_Report_PHP;
$COVERAGE_DIRECTORY = '/tmp/coverage';
if (!file_exists($COVERAGE_DIRECTORY)){
mkdir($COVERAGE_DIRECTORY);
}
$writer->process($_____coverage, tempnam($COVERAGE_DIRECTORY, 'coverage'));
}
@twogood
Copy link
Author

twogood commented Dec 20, 2012

cd /tmp/coverage chown -R a+r . for f in *; do mv basename $f .cov $f.cov; done phpcov --html /tmp/cov-html/ --merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment