public function generate()
 {
     CoverageUtils::mkdir($this->reportDir);
     $index = $this->reportDir . '/index.html';
     $hnd = fopen($index, 'w');
     $this->generateSummaryReport($hnd);
     fclose($hnd);
     foreach ($this->coverage as $file => $cov) {
         $byFile = $this->reportDir . '/' . self::reportFilename($file);
         $byFileHnd = fopen($byFile, 'w');
         $this->generateCoverageByFile($byFileHnd, $file, $cov);
         fclose($byFileHnd);
     }
     echo "generated report {$index}\n";
 }
 function testIssetOr()
 {
     $data = array('bird' => 'gull');
     $this->assertEqual('lab', CoverageUtils::issetOr($data['dog'], 'lab'));
     $this->assertEqual('gull', CoverageUtils::issetOr($data['bird'], 'sparrow'));
 }
<?php

/**
 * Generate a code coverage report
 *
 * @package        SimpleTest
 * @subpackage     Extensions
 */
# optional arguments:
#  --reportDir=some/directory    the default is ./coverage-report
#  --title='My Coverage Report'  title the main page of your report
/**#@+
 * include coverage files
 */
require_once dirname(__FILE__) . '/../coverage_utils.php';
require_once dirname(__FILE__) . '/../coverage.php';
require_once dirname(__FILE__) . '/../coverage_reporter.php';
/**#@-*/
$cc = CodeCoverage::getInstance();
$cc->readSettings();
$handler = new CoverageDataHandler($cc->log);
$report = new CoverageReporter();
$args = CoverageUtils::parseArguments($_SERVER['argv']);
$report->reportDir = CoverageUtils::issetOr($args['reportDir'], 'coverage-report');
$report->title = CoverageUtils::issetOr($args['title'], "Simpletest Coverage");
$report->coverage = $handler->read();
$report->untouched = $handler->readUntouchedFiles();
$report->generate();
<?php

/**
 * Initialize code coverage data collection, next step is to run your tests
 * with ini setting auto_prepend_file=autocoverage.php ...
 *
 * @package        SimpleTest
 * @subpackage     Extensions
 */
# optional arguments:
#  --include=<some filepath regexp>      these files should be included coverage report
#  --exclude=<come filepath regexp>      these files should not be included in coverage report
#  --maxdepth=2                          when considering which file were not touched, scan directories
#
# Example:
# php-coverage-open.php --include='.*\.php$' --include='.*\.inc$' --exclude='.*/tests/.*'
/**#@+
 * include coverage files
 */
require_once dirname(__FILE__) . '/../coverage_utils.php';
CoverageUtils::requireSqlite();
require_once dirname(__FILE__) . '/../coverage.php';
/**#@-*/
$cc = new CodeCoverage();
$cc->log = 'coverage.sqlite';
$args = CoverageUtils::parseArguments($_SERVER['argv'], TRUE);
$cc->includes = CoverageUtils::issetOr($args['include[]'], array('.*\\.php$'));
$cc->excludes = CoverageUtils::issetOr($args['exclude[]']);
$cc->maxDirectoryDepth = (int) CoverageUtils::issetOr($args['maxdepth'], '1');
$cc->resetLog();
$cc->writeSettings();