2010-10-19 05:06:55 +02:00
|
|
|
<?php
|
2010-10-19 05:35:14 +02:00
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage dev
|
|
|
|
*/
|
2010-10-19 05:06:55 +02:00
|
|
|
|
|
|
|
class PhpUnitWrapper_3_5 extends PhpUnitWrapper {
|
|
|
|
|
2011-03-11 02:45:49 +01:00
|
|
|
protected $version = 'PhpUnit V3.5';
|
|
|
|
|
2010-10-19 05:06:55 +02:00
|
|
|
protected $coverage = null;
|
|
|
|
|
|
|
|
protected static $test_name = 'SapphireTest';
|
|
|
|
|
|
|
|
static function get_test_name() {
|
|
|
|
return self::$test_name;
|
|
|
|
}
|
|
|
|
|
2010-10-19 05:35:14 +02:00
|
|
|
/**
|
|
|
|
* Initialise the wrapper class.
|
|
|
|
*/
|
2010-10-19 05:06:55 +02:00
|
|
|
public function init() {
|
|
|
|
require_once 'PHP/CodeCoverage.php';
|
|
|
|
require_once 'PHP/CodeCoverage/Report/HTML.php';
|
|
|
|
|
|
|
|
require_once 'PHPUnit/Autoload.php';
|
|
|
|
|
|
|
|
require_once 'PHP/CodeCoverage/Filter.php';
|
|
|
|
}
|
|
|
|
|
2010-10-19 05:35:14 +02:00
|
|
|
/**
|
|
|
|
* Overwrites beforeRunTests. Initiates coverage-report generation if
|
|
|
|
* $coverage has been set to true (@see setCoverageStatus).
|
|
|
|
*/
|
2010-10-19 05:06:55 +02:00
|
|
|
protected function beforeRunTests() {
|
|
|
|
|
|
|
|
if($this->getCoverageStatus()) {
|
2010-10-19 05:35:14 +02:00
|
|
|
$this->coverage = new PHP_CodeCoverage();
|
2010-10-19 05:06:55 +02:00
|
|
|
$coverage = $this->coverage;
|
|
|
|
|
|
|
|
$filter = $coverage->filter();
|
|
|
|
|
|
|
|
foreach(TestRunner::$coverage_filter_dirs as $dir) {
|
|
|
|
$filter->addDirectoryToBlacklist(BASE_PATH . '/' . $dir);
|
|
|
|
}
|
2011-11-07 23:26:40 +01:00
|
|
|
|
|
|
|
$filter->addFileToBlacklist(__FILE__, 'PHPUNIT');
|
2010-10-19 05:06:55 +02:00
|
|
|
|
|
|
|
$coverage->start(self::get_test_name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-19 05:35:14 +02:00
|
|
|
/**
|
|
|
|
* Overwrites aferRunTests. Creates coverage report and clover report
|
|
|
|
* if required.
|
|
|
|
*/
|
2010-10-19 05:06:55 +02:00
|
|
|
protected function aferRunTests() {
|
|
|
|
|
|
|
|
if($this->getCoverageStatus()) {
|
|
|
|
$coverage = $this->coverage;
|
|
|
|
$coverage->stop();
|
|
|
|
|
2010-10-19 05:35:14 +02:00
|
|
|
$writer = new PHP_CodeCoverage_Report_HTML();
|
2010-10-19 05:06:55 +02:00
|
|
|
$writer->process($coverage, ASSETS_PATH.'/code-coverage-report');
|
|
|
|
}
|
|
|
|
}
|
2010-10-19 05:35:14 +02:00
|
|
|
|
2010-10-19 05:06:55 +02:00
|
|
|
}
|