Making CodeCoverageManager and CakeSession tests run in php4. Removing test case for removed method.

This commit is contained in:
Mark Story 2010-01-14 22:47:49 -05:00
parent 2093f05ce7
commit 5d280ea977
2 changed files with 4 additions and 165 deletions

View file

@ -167,6 +167,7 @@ class SessionTest extends CakeTestCase {
$this->assertTrue($this->Session->started());
unset($_SESSION);
$_SESSION = null;
$this->assertFalse($this->Session->started());
$this->assertTrue($this->Session->start());
}

View file

@ -139,173 +139,11 @@ class CodeCoverageManagerTest extends CakeTestCase {
$this->assertIdentical(APP.'plugins'.DS.'bugs'.DS.'models'.DS.'some_file.php', $expected);
$manager->pluginTest = false;
$manager->reporter = new CLIReporter;
$manager->reporter = new CakeCliReporter;
$expected = $manager->__testObjectFileFromCaseFile('libs/set.test.php', false);
$this->assertIdentical(ROOT.DS.'cake'.DS.'libs'.DS.'set.php', $expected);
}
/**
* testOfHtmlReport method
*
* @access public
* @return void
*/
function testOfHtmlReport() {
$manager =& CodeCoverageManager::getInstance();
$code = <<<PHP
/**
* Set class
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class Set extends Object {
/**
* Value of the Set object.
*
* @var array
* @access public
*/
var \$value = array();
/**
* Constructor. Defaults to an empty array.
*
* @access public
*/
function __construct() {
if (func_num_args() == 1 && is_array(func_get_arg(0))) {
\$this->value = func_get_arg(0);
} else {
\$this->value = func_get_args();
}
}
/**
* Returns the contents of the Set object
*
* @return array
* @access public
*/
function &get() {
return \$this->value;
}
/**
* This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
* to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
* but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.
*
* Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
*
* @param array \$arr1 Array to be merged
* @param array \$arr2 Array to merge with
* @return array Merged array
* @access public
*/
function merge(\$arr1, \$arr2 = null) {
\$args = func_get_args();
if (isset(\$this) && is_a(\$this, 'set')) {
\$backtrace = debug_backtrace();
\$previousCall = strtolower(\$backtrace[1]['class'].'::'.\$backtrace[1]['function']);
if (\$previousCall != 'set::merge') {
\$r =& \$this->value;
array_unshift(\$args, null);
}
}
if (!isset(\$r)) {
\$r = (array)current(\$args);
}
while ((\$arg = next(\$args)) !== false) {
if (is_a(\$arg, 'set')) {
\$arg = \$arg->get();
}
foreach ((array)\$arg as \$key => \$val) {
if (is_array(\$val) && isset(\$r[\$key]) && is_array(\$r[\$key])) {
\$r[\$key] = Set::merge(\$r[\$key], \$val);
} elseif (is_int(\$key)) {
} else {
\$r[\$key] = \$val;
}
}
}
return \$r;
}
PHP;
$testObjectFile = explode("\n", $code);
$coverageData = array(
0 => 1,
1 => 1,
2 => -2,
3 => -2,
4 => -2,
5 => -2,
6 => -2,
7 => -2,
8 => -1,
9 => -2,
10 => -2,
11 => -2,
12 => -2,
13 => -2,
14 => 1,
15 => 1,
16 => -1,
17 => 1,
18 => 1,
19 => -1,
20 => 1,
21 => -2,
22 => -2,
23 => -2,
24 => -2,
25 => -2,
26 => -2,
27 => 1,
28 => -1,
29 => 1,
30 => 1,
31 => -2,
32 => -2,
33 => -2,
34 => -2,
35 => -2,
36 => -2,
37 => -2,
38 => -2,
39 => -2,
40 => -2,
41 => -2,
42 => -2,
43 => -1,
);
$execCodeLines = range(0, 72);
$result = explode("</div>", $report = $manager->reportCaseHtml($testObjectFile, $coverageData, $execCodeLines));
foreach ($result as $num => $line) {
$num++;
if (array_key_exists($num, $coverageData)) {
if ($coverageData[$num] == 1) {
$this->assertTrue(strpos($line, 'covered') !== false, $num.': '.$line." fails");
}
if (!array_key_exists($num, $execCodeLines) || $coverageData[$num] == -2) {
$this->assertTrue(strpos($line, 'ignored') !== false, $num.': '.$line." fails");
}
if ($coverageData[$num] == -1) {
$this->assertTrue(strpos($line, 'uncovered') !== false, $num.': '.$line." fails");
}
}
}
}
/**
* testOfHtmlDiffReport method
*