Fixing several issues in the CodeCoverageManager test case.

This commit is contained in:
Mark Story 2010-01-16 20:14:16 -05:00
parent c4ef429004
commit f1276ce337

View file

@ -63,7 +63,9 @@ class CodeCoverageManagerTest extends CakeTestCase {
* @return void * @return void
*/ */
function testNoTestCaseSupplied() { function testNoTestCaseSupplied() {
if (PHP_SAPI != 'cli') { 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)); $reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter); CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter);
@ -73,7 +75,18 @@ class CodeCoverageManagerTest extends CakeTestCase {
CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter); CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
CodeCoverageManager::report(false); CodeCoverageManager::report(false);
$this->assertError(); $this->assertError();
}
/**
* Test that test cases don't cause errors
*
* @return void
*/
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; $path = LIBS;
if (strpos(LIBS, ROOT) === false) { if (strpos(LIBS, ROOT) === false) {
$path = ROOT.DS.LIBS; $path = ROOT.DS.LIBS;
@ -83,17 +96,7 @@ class CodeCoverageManagerTest extends CakeTestCase {
$folder->cd($path); $folder->cd($path);
$contents = $folder->read(); $contents = $folder->read();
/** $contents[1] = array_filter($contents[1], array(&$this, '_basenameFilter'));
* remove method
*
* @param mixed $var
* @access public
* @return void
*/
function remove($var) {
return ($var != basename(__FILE__));
}
$contents[1] = array_filter($contents[1], "remove");
foreach ($contents[1] as $file) { foreach ($contents[1] as $file) {
CodeCoverageManager::init('libs' . DS . $file, $reporter); CodeCoverageManager::init('libs' . DS . $file, $reporter);
@ -101,6 +104,14 @@ class CodeCoverageManagerTest extends CakeTestCase {
$this->assertNoErrors('libs' . DS . $file); $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__));
} }
/** /**