2010-10-19 05:06:55 +02:00
|
|
|
<?php
|
2010-10-19 05:35:14 +02:00
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2010-10-19 05:35:14 +02:00
|
|
|
* @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';
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public static function get_test_name() {
|
2010-10-19 05:06:55 +02:00
|
|
|
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() {
|
2013-01-23 02:30:08 +01:00
|
|
|
if(!class_exists('PHPUnit_Framework_TestCase')) {
|
|
|
|
require_once 'PHP/CodeCoverage.php';
|
|
|
|
require_once 'PHP/CodeCoverage/Report/HTML.php';
|
2010-10-19 05:06:55 +02:00
|
|
|
|
2013-01-23 02:30:08 +01:00
|
|
|
require_once 'PHPUnit/Autoload.php';
|
2010-10-19 05:06:55 +02:00
|
|
|
|
2013-01-23 02:30:08 +01:00
|
|
|
require_once 'PHP/CodeCoverage/Filter.php';
|
|
|
|
}
|
2010-10-19 05:06:55 +02:00
|
|
|
}
|
|
|
|
|
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()) {
|
2012-12-08 12:20:20 +01:00
|
|
|
$this->coverage = new PHP_CodeCoverage();
|
2010-10-19 05:06:55 +02:00
|
|
|
$coverage = $this->coverage;
|
|
|
|
|
2012-12-08 12:20:20 +01:00
|
|
|
$filter = $coverage->filter();
|
|
|
|
$modules = $this->moduleDirectories();
|
2010-10-19 05:06:55 +02:00
|
|
|
|
|
|
|
foreach(TestRunner::$coverage_filter_dirs as $dir) {
|
2012-03-24 04:38:57 +01:00
|
|
|
if($dir[0] == '*') {
|
|
|
|
$dir = substr($dir, 1);
|
|
|
|
foreach ($modules as $module) {
|
|
|
|
$filter->addDirectoryToBlacklist(BASE_PATH . "/$module/$dir");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$filter->addDirectoryToBlacklist(BASE_PATH . '/' . $dir);
|
|
|
|
}
|
2010-10-19 05:06:55 +02:00
|
|
|
}
|
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
|
|
|
|
2012-03-24 04:38:57 +01:00
|
|
|
}
|