Skip to content

Commit

Permalink
Making coverage reports work from the webrunner.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 13, 2011
1 parent 16481d7 commit 08fba9b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
24 changes: 23 additions & 1 deletion cake/tests/lib/cake_test_runner.php
Expand Up @@ -21,11 +21,20 @@
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');

/**
* Class to customize loading of test suites from CLI
* A custom test runner for Cake's use of PHPUnit.
*
* @package cake.tests.lib
*/
class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
/**
* Lets us pass in some options needed for cake's webrunner.
*
* @return void
*/
public function __construct($loader, $params) {
parent::__construct($loader);
$this->_params = $params;
}

/**
* Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager
Expand All @@ -52,6 +61,19 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
return $return;
}

/**
* Create the test result and splice on our code coverage reports.
*
* @return PHPUnit_Framework_TestResult
*/
protected function createTestResult() {
$result = new PHPUnit_Framework_TestResult;
if (isset($this->_params['codeCoverage'])) {
$result->collectCodeCoverageInformation(true);
}
return $result;
}

/**
* Get the fixture manager class specified or use the default one.
*
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/cake_test_suite_command.php
Expand Up @@ -62,7 +62,7 @@ public function run(array $argv, $exit = TRUE)
{
$this->handleArguments($argv);

$runner = new CakeTestRunner($this->arguments['loader']);
$runner = new CakeTestRunner($this->arguments['loader'], $this->_params);

if (is_object($this->arguments['test']) &&
$this->arguments['test'] instanceof PHPUnit_Framework_Test) {
Expand Down
24 changes: 0 additions & 24 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Expand Up @@ -38,14 +38,6 @@ class CakeTestSuiteDispatcher {
'show_passes' => false,
'filter' => false
);

/**
* The Instance of the Manager being used.
*
* @var TestManager subclass
*/
public $Manager;

/**
* Baseurl for the request
*
Expand Down Expand Up @@ -185,20 +177,6 @@ function _testCaseList() {
$Reporter->paintDocumentEnd();
}

/**
* Sets the Manager to use for the request.
*
* @return string The manager class name
* @static
*/
function &getManager() {
if (empty($this->Manager)) {
require_once CAKE_TESTS_LIB . 'test_manager.php';
$this->Manager = new $this->_managerClass($this->params);
}
return $this->Manager;
}

/**
* Gets the reporter based on the request parameters
*
Expand Down Expand Up @@ -268,8 +246,6 @@ function _parseParams() {
function _runTestCase() {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';

$Reporter = CakeTestSuiteDispatcher::getReporter();

$commandArgs = array(
'case' => $this->params['case'],
'core' =>$this->params['core'],
Expand Down
1 change: 0 additions & 1 deletion cake/tests/lib/test_manager.php
Expand Up @@ -16,7 +16,6 @@
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
var_dump(debug_backtrace());
define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases');
define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups');
define('APP_TEST_CASES', TESTS . 'cases');
Expand Down

0 comments on commit 08fba9b

Please sign in to comment.