diff --git a/cake/tests/lib/cake_fixture_manager.php b/cake/tests/lib/cake_fixture_manager.php index b50b879c8..b6f75f27c 100644 --- a/cake/tests/lib/cake_fixture_manager.php +++ b/cake/tests/lib/cake_fixture_manager.php @@ -1,5 +1,7 @@ params['codeCoverage'] = true; - require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; $this->_checkXdebug(); + require_once CAKE_TESTS_LIB . 'code_coverage_manager.php'; } $this->params['baseUrl'] = $this->_baseUrl; $this->params['baseDir'] = $this->_baseDir; @@ -254,7 +256,7 @@ class CakeTestSuiteDispatcher { if ('all' == $this->params['group']) { $this->Manager->runAllTests($Reporter); } else { - $this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter); + $this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter, $this->params['codeCoverage']); } } @@ -268,7 +270,7 @@ class CakeTestSuiteDispatcher { if ($this->params['codeCoverage']) { CodeCoverageManager::init($this->params['case'], $Reporter); } - $this->Manager->runTestCase($this->params['case'], $Reporter); + $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']); } } ?> \ No newline at end of file diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index c0b5653f9..d1455462c 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -18,6 +18,8 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ +PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT'); + /** * CakeBaseReporter contains common reporting features used in the CakePHP Test suite * diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 8380adf9e..68d6dbd09 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -19,6 +19,8 @@ */ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; +PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT'); + /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. @@ -178,7 +180,7 @@ class CakeHtmlReporter extends CakeBaseReporter implements PHPUnit_Framework_Tes $this->params['codeCoverage'] && class_exists('CodeCoverageManager') ) { - CodeCoverageManager::report(); + //CodeCoverageManager::report(); } $this->paintDocumentEnd(); } diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index a9c14bade..07bb09993 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -22,6 +22,8 @@ define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups' define('APP_TEST_CASES', TESTS . 'cases'); define('APP_TEST_GROUPS', TESTS . 'groups'); +PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT'); + /** * TestManager is the base class that handles loading and initiating the running * of TestCase and TestSuite classes that the user has selected. @@ -113,7 +115,7 @@ class TestManager { * @throws InvalidArgumentException if the supplied $testCaseFile does not exists * @return mixed Result of test case being run. */ - public function runTestCase($testCaseFile, PHPUnit_Framework_TestListener $reporter) { + public function runTestCase($testCaseFile, PHPUnit_Framework_TestListener $reporter, $codeCoverage = false) { $testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile; if (!file_exists($testCaseFileWithPath)) { @@ -122,7 +124,7 @@ class TestManager { $testSuite = $this->getTestSuite(sprintf(__('Individual test case: %s', true), $testCaseFile)); $testSuite->addTestFile($testCaseFileWithPath); - return $this->run($reporter); + return $this->run($reporter, $codeCoverage); } /** @@ -133,7 +135,7 @@ class TestManager { * @throws InvalidArgumentException if it was not possible to locate the filename for $groupTestName * @return mixed Results of group test being run. */ - public function runGroupTest($groupTestName, $reporter) { + public function runGroupTest($groupTestName, $reporter, $codeCoverage = false) { $filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->getExtension('group'); if (!file_exists($filePath)) { @@ -149,7 +151,7 @@ class TestManager { $suite->setName($group->label); } - return $this->run($reporter); + return $this->run($reporter, $codeCoverage); } /** @@ -158,12 +160,16 @@ class TestManager { * @param PHPUnit_Framework_TestListener $reporter Reporter instance to use with the group test being run. * @return mixed Results of group test being run. */ - protected function run($reporter) { + protected function run($reporter, $codeCoverage = false) { $result = new PHPUnit_Framework_TestResult; + $result->collectCodeCoverageInformation($codeCoverage); $result->addListener($reporter); $reporter->paintHeader(); $this->getTestSuite()->run($result); $reporter->paintResult($result); + // echo '
'; + // var_dump($result->getCodeCoverageInformation()); + // echo ''; return $result; }