silverstripe-framework/dev/phpunit/PhpUnitWrapper_3_4.php
Ingo Schommer 73784b416a MINOR: added phpdoc to the new PHPUnitWrapper classes.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@111042 467b73ca-7a2a-4603-9d3b-597d59a354a9
2011-02-02 14:19:51 +13:00

63 lines
1.8 KiB
PHP

<?php
/**
* @package sapphire
* @subpackage dev
*/
/**
* PHPUnit Wrapper class. Implements the correct behaviour for PHPUnit V3.4.
*/
class PhpUnitWrapper_3_4 extends PhpUnitWrapper {
protected $version = 'PhpUnit V3.4';
/**
* Initialise the wrapper class.
*/
public function init() {
parent::init();
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Util/Report.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
}
/**
* Overwrites beforeRunTests. Initiates coverage-report generation if
* $coverage has been set to true (@see setCoverageStatus).
*/
protected function beforeRunTests() {
if($this->getCoverageStatus()) {
// blacklist selected folders from coverage report
foreach(TestRunner::$coverage_filter_dirs as $dir) {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
$this->getFrameworkTestResults()->collectCodeCoverageInformation(true);
}
}
/**
* Overwrites aferRunTests. Creates coverage report and clover report
* if required.
*/
protected function aferRunTests() {
if($this->getCoverageStatus()) {
if(!file_exists(ASSETS_PATH . '/coverage-report')) {
mkdir(ASSETS_PATH . '/coverage-report');
}
$ret = PHPUnit_Util_Report::render($this->getFrameworkTestResults(), ASSETS_PATH . '/coverage-report/');
$coverageApp = ASSETS_PATH . '/coverage-report/' . preg_replace('/[^A-Za-z0-9]/','_',preg_replace('/(\/$)|(^\/)/','',Director::baseFolder())) . '.html';
$coverageTemplates = ASSETS_PATH . '/coverage-report/' . preg_replace('/[^A-Za-z0-9]/','_',preg_replace('/(\/$)|(^\/)/','',realpath(TEMP_FOLDER))) . '.html';
echo "<p>Coverage reports available here:<ul>
<li><a href=\"$coverageApp\">Coverage report of the application</a></li>
<li><a href=\"$coverageTemplates\">Coverage report of the templates</a></li>
</ul>";
}
}
}