Browse files

Updating CodeCoverageManager test case and CodeCoverageManager

  • Loading branch information...
1 parent cf5c48e commit 836c7de7cb23f3c346985940275f7a05dc07ec62 @markstory markstory committed Jan 10, 2010
Showing with 26 additions and 11 deletions.
  1. +5 −5 cake/tests/cases/libs/code_coverage_manager.test.php
  2. +21 −6 cake/tests/lib/code_coverage_manager.php
View
10 cake/tests/cases/libs/code_coverage_manager.test.php
@@ -19,7 +19,6 @@
*/
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php';
-require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_reporter.php';
/**
* CodeCoverageManagerTest class
@@ -65,12 +64,13 @@ function endCase() {
*/
function testNoTestCaseSupplied() {
if (PHP_SAPI != 'cli') {
- unset($_GET['group']);
- CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
+ $reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
+
+ CodeCoverageManager::start(substr(md5(microtime()), 0, 5), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
- CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), new CakeHtmlReporter());
+ CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
@@ -96,7 +96,7 @@ function remove($var) {
$contents[1] = array_filter($contents[1], "remove");
foreach ($contents[1] as $file) {
- CodeCoverageManager::start('libs'.DS.$file, new CakeHtmlReporter());
+ CodeCoverageManager::start('libs'.DS.$file, $reporter);
CodeCoverageManager::report(false);
$this->assertNoErrors('libs'.DS.$file);
}
View
27 cake/tests/lib/code_coverage_manager.php
@@ -93,6 +93,7 @@ function &getInstance() {
* @param string $testCaseFile
* @param string $reporter
* @return void
+ * @static
*/
function start($testCaseFile, &$reporter) {
$manager =& CodeCoverageManager::getInstance();
@@ -103,26 +104,35 @@ function start($testCaseFile, &$reporter) {
if (strpos($testCaseFile, $thisFile) !== false) {
trigger_error('Xdebug supports no parallel coverage analysis - so this is not possible.', E_USER_ERROR);
}
-
+ $manager->setParams($reporter);
+ $manager->testCaseFile = $testCaseFile;
+ xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
+ }
+
+/**
+ * Set the parameters from a reporter to the CodeCoverageManager
+ *
+ * @return void
+ */
+ function setParams(&$reporter) {
if ($reporter->params['app']) {
- $manager->appTest = true;
+ $this->appTest = true;
}
if ($reporter->params['group']) {
- $manager->groupTest = true;
+ $this->groupTest = true;
}
if ($reporter->params['plugin']) {
- $manager->pluginTest = Inflector::underscore($reporter->params['plugin']);
+ $this->pluginTest = Inflector::underscore($reporter->params['plugin']);
}
- $manager->testCaseFile = $testCaseFile;
- xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}
/**
* Stops the current code coverage analyzation and dumps a nice report depending on the reporter that was passed to start()
*
* @return void
+ * @static
*/
function report($output = true) {
$manager =& CodeCoverageManager::getInstance();
@@ -212,6 +222,7 @@ function report($output = true) {
* @param string $execCodeLines
* @param string $output
* @return void
+ * @static
*/
function reportCaseHtml($testObjectFile, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();
@@ -248,6 +259,7 @@ function reportCaseHtml($testObjectFile, $coverageData, $execCodeLines) {
* @param string $execCodeLines
* @param string $output
* @return void
+ * @static
*/
function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) {
$manager = CodeCoverageManager::getInstance();
@@ -366,6 +378,7 @@ function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $num
* @param string $execCodeLines
* @param string $output
* @return void
+ * @static
*/
function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();
@@ -396,6 +409,7 @@ function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
* @param string $execCodeLines
* @param string $output
* @return void
+ * @static
*/
function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) {
$manager = CodeCoverageManager::getInstance();
@@ -436,6 +450,7 @@ function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numCo
* @param string $execCodeLines
* @param string $output
* @return void
+ * @static
*/
function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();

0 comments on commit 836c7de

Please sign in to comment.