2014-04-17 15:14:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic PhpUnitWrapper.
|
|
|
|
* Originally intended for use with Composer based installations, but will work
|
|
|
|
* with any fully functional autoloader.
|
|
|
|
*/
|
|
|
|
class PhpUnitWrapper_Generic extends PhpUnitWrapper {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a version string, like 3.7.34 or 4.2-dev.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getVersion() {
|
|
|
|
return PHPUnit_Runner_Version::id();
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2014-04-17 15:14:51 +02:00
|
|
|
protected $coverage = null;
|
|
|
|
|
|
|
|
protected static $test_name = 'SapphireTest';
|
|
|
|
|
|
|
|
public static function get_test_name() {
|
|
|
|
return static::$test_name;
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2014-04-17 15:14:51 +02:00
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* Overwrites beforeRunTests. Initiates coverage-report generation if
|
2014-04-17 15:14:51 +02:00
|
|
|
* $coverage has been set to true (@see setCoverageStatus).
|
|
|
|
*/
|
|
|
|
protected function beforeRunTests() {
|
2014-08-15 08:53:05 +02:00
|
|
|
|
|
|
|
if($this->getCoverageStatus()) {
|
2014-04-17 15:14:51 +02:00
|
|
|
$this->coverage = new PHP_CodeCoverage();
|
|
|
|
$coverage = $this->coverage;
|
|
|
|
|
|
|
|
$filter = $coverage->filter();
|
|
|
|
$modules = $this->moduleDirectories();
|
|
|
|
|
|
|
|
foreach(TestRunner::config()->coverage_filter_dirs as $dir) {
|
|
|
|
if($dir[0] == '*') {
|
|
|
|
$dir = substr($dir, 1);
|
|
|
|
foreach ($modules as $module) {
|
|
|
|
$filter->addDirectoryToBlacklist(BASE_PATH . "/$module/$dir");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$filter->addDirectoryToBlacklist(BASE_PATH . '/' . $dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$filter->addFileToBlacklist(__FILE__, 'PHPUNIT');
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2014-04-17 15:14:51 +02:00
|
|
|
$coverage->start(self::get_test_name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Overwrites afterRunTests. Creates coverage report and clover report
|
|
|
|
* if required.
|
|
|
|
*/
|
|
|
|
protected function afterRunTests() {
|
|
|
|
|
|
|
|
if($this->getCoverageStatus()) {
|
|
|
|
$coverage = $this->coverage;
|
|
|
|
$coverage->stop();
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2014-04-17 15:14:51 +02:00
|
|
|
$writer = new PHP_CodeCoverage_Report_HTML();
|
|
|
|
$writer->process($coverage, ASSETS_PATH.'/code-coverage-report');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|