Skip to content

Instantly share code, notes, and snippets.

@jrbasso
Created August 4, 2012 21:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jrbasso/3260166 to your computer and use it in GitHub Desktop.
Save jrbasso/3260166 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 self('All Application Tests');
$suite->addTestDirectoryRecursive(dirname(__FILE__));
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();
if ($coverage) { // If the CodeCoverage is not installed or disabled
$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);
}
}
@TiuTalk
Copy link

TiuTalk commented Aug 11, 2012

Fatal Error

Error: Call to a member function setProcessUncoveredFilesFromWhitelist() on a non-object
File: Test/Case/AllAppTest.php
Line: 22

@jrbasso
Copy link
Author

jrbasso commented Aug 20, 2012

@TiuTalk It happened probably because you didn't have the code coverage installed. I updated the code, including the if statement to avoid that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment