Skip to content

Commit

Permalink
Fixing several issues in the CodeCoverageManager test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 17, 2010
1 parent c4ef429 commit f1276ce
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions cake/tests/cases/libs/code_coverage_manager.test.php
Expand Up @@ -63,46 +63,57 @@ function endCase() {
* @return void
*/
function testNoTestCaseSupplied() {
if (PHP_SAPI != 'cli') {
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));

CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
return;
}
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));

CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter);
CodeCoverageManager::report(false);
$this->assertError();

$path = LIBS;
if (strpos(LIBS, ROOT) === false) {
$path = ROOT.DS.LIBS;
}
App::import('Core', 'Folder');
$folder = new Folder();
$folder->cd($path);
$contents = $folder->read();
CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
CodeCoverageManager::report(false);
$this->assertError();
}

/**
* remove method
* Test that test cases don't cause errors
*
* @param mixed $var
* @access public
* @return void
*/
function remove($var) {
return ($var != basename(__FILE__));
}
$contents[1] = array_filter($contents[1], "remove");
function testNoTestCaseSuppliedNoErrors() {
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
return;
}
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
$path = LIBS;
if (strpos(LIBS, ROOT) === false) {
$path = ROOT.DS.LIBS;
}
App::import('Core', 'Folder');
$folder = new Folder();
$folder->cd($path);
$contents = $folder->read();

foreach ($contents[1] as $file) {
CodeCoverageManager::init('libs' . DS . $file, $reporter);
CodeCoverageManager::report(false);
$this->assertNoErrors('libs' . DS . $file);
}
$contents[1] = array_filter($contents[1], array(&$this, '_basenameFilter'));

foreach ($contents[1] as $file) {
CodeCoverageManager::init('libs' . DS . $file, $reporter);
CodeCoverageManager::report(false);
$this->assertNoErrors('libs' . DS . $file);
}
}

/**
* Remove file names that don't share a basename with the current file.
*
* @return void
*/
function _basenameFilter($var) {
return ($var != basename(__FILE__));
}

/**
* testGetTestObjectFileNameFromTestCaseFile method
*
Expand Down

0 comments on commit f1276ce

Please sign in to comment.