Fixing CodeCoverageManagerTest for PHP4 command line call under Windows. Fixing issue in CodeCoverageManager where wrong path was created on Windows.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6791 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-05-10 17:01:51 +00:00
parent b8f0e80f7d
commit 88f25d501b
2 changed files with 34 additions and 41 deletions

View file

@ -36,22 +36,18 @@ require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_reporter.php';
* @subpackage cake.tests.cases.libs
*/
class CodeCoverageManagerTest extends UnitTestCase {
/**
* Test that invalid supplied files will raise an error; test if random library files can be analyzed without errors
*
*/
function testNoTestCaseSupplied() {
if (php_sapi_name() != 'cli') { // assertError seems to be not working for cli reports
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter);
if (!in_array(php_sapi_name(), array('cli', 'cgi-fcgi'))) {
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertError();
CodeCoverageManager::start('libs/'.basename(__FILE__), new CakeHtmlReporter);
CodeCoverageManager::start('libs/'.basename(__FILE__), new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertError();
$path = LIBS;
if (strpos(LIBS, ROOT) === false) { // cli fix
if (strpos(LIBS, ROOT) === false) {
$path = ROOT.DS.LIBS;
}
App::import('Core', 'Folder');
@ -65,7 +61,7 @@ class CodeCoverageManagerTest extends UnitTestCase {
$contents[1] = array_filter($contents[1], "remove");
$keys = array_rand($contents[1], 5);
foreach ($keys as $key) {
CodeCoverageManager::start('libs'.DS.$contents[1][$key], new CakeHtmlReporter);
CodeCoverageManager::start('libs'.DS.$contents[1][$key], new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertNoErrors();
}
@ -73,9 +69,9 @@ class CodeCoverageManagerTest extends UnitTestCase {
}
function testGetTestObjectFileNameFromTestCaseFile() {
$manager = CodeCoverageManager::getInstance();
$manager =& CodeCoverageManager::getInstance();
$manager->reporter = new CakeHtmlReporter();
$manager->reporter = new CakeHtmlReporter;
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);
@ -105,7 +101,7 @@ class CodeCoverageManagerTest extends UnitTestCase {
}
function testOfHtmlReport() {
$manager = CodeCoverageManager::getInstance();
$manager =& CodeCoverageManager::getInstance();
$code = <<<PHP
class Set extends Object {
/**
@ -251,7 +247,7 @@ PHP;
}
function testOfHtmlDiffReport() {
$manager = CodeCoverageManager::getInstance();
$manager =& CodeCoverageManager::getInstance();
$code = <<<PHP
class Set extends Object {
/**
@ -499,7 +495,7 @@ PHP;
}
function testArrayStrrpos() {
$manager = CodeCoverageManager::getInstance();
$manager =& CodeCoverageManager::getInstance();
$a = array(
'apples',
@ -526,9 +522,9 @@ PHP;
}
function testGetExecutableLines() {
$manager = CodeCoverageManager::getInstance();
$manager =& CodeCoverageManager::getInstance();
$code = <<<HTML
\$manager = CodeCoverageManager::getInstance();
\$manager =& CodeCoverageManager::getInstance();
HTML;
$result = $manager->__getExecutableLines($code);
foreach ($result as $line) {
@ -558,7 +554,7 @@ HTML;
}
function testCalculateCodeCoverage() {
$manager = CodeCoverageManager::getInstance();
$manager =& CodeCoverageManager::getInstance();
$data = array(
'25' => array(100, 25),
'50' => array(100, 50),

View file

@ -489,12 +489,9 @@ class CodeCoverageManager {
}
$testManager =& new TestManager();
$testFile = str_replace($testManager->_testExtension, '.php', $file);
$testFile = str_replace(array('/', $testManager->_testExtension), array(DS, '.php'), $file);
// if this is a file from the test lib, we cannot find the test object file in /cake/libs
// but need to search for it in /cake/test/lib
// would be cool if we could maybe change the test suite folder layout
$folder = new Folder();
$folder =& new Folder();
$folder->cd(ROOT.DS.CAKE_TESTS_LIB);
$contents = $folder->ls();