Skip to content

Instantly share code, notes, and snippets.

@evilbloodydemon
Forked from jrbasso/AllAppTest.php
Created August 5, 2012 05:54
Show Gist options
  • Select an option

  • Save evilbloodydemon/3262118 to your computer and use it in GitHub Desktop.

Select an option

Save evilbloodydemon/3262118 to your computer and use it in GitHub Desktop.
All application tests ignoring CakePHP core files from Code Coverage
<?php
class AllAppTest extends CakeTestSuite {
protected $coverageSetup = false;
public static function suite() {
$suite = new static('All Application Tests');
$suite->addTestDirectoryRecursive(__DIR__);
return $suite;
}
public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE) {
if ($result === NULL) {
$result = $this->createResult();
}
if (!$this->coverageSetup) {
$coverage = $result->getCodeCoverage();
$coverage->setProcessUncoveredFilesFromWhitelist(true);
$coverageFilter = $coverage->filter();
$coverageFilter->addDirectoryToBlacklist(APP . DS . 'Test');
$coverageFilter->addDirectoryToBlacklist(CORE_PATH);
$this->coverageSetup = true;
}
return parent::run($result, $filter, $groups, $excludeGroups, $processIsolation);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment