Skip to content
Browse files

Fixing test cases and php4 compatibility in Debugger.

  • Loading branch information...
1 parent f2dc207 commit d4d9ed7bfe114afa0eb88c1f42f8033569c5f6c7 @markstory markstory committed
Showing with 20 additions and 20 deletions.
  1. +6 −6 cake/libs/debugger.php
  2. +14 −14 cake/tests/cases/libs/debugger.test.php
View
12 cake/libs/debugger.php
@@ -213,7 +213,7 @@ function &getInstance($class = null) {
* @link http://book.cakephp.org/view/460/Using-the-Debugger-Class
*/
function dump($var) {
- $_this = Debugger::getInstance();
+ $_this =& Debugger::getInstance();
pr($_this->exportVar($var));
}
@@ -228,7 +228,7 @@ function dump($var) {
* @link http://book.cakephp.org/view/460/Using-the-Debugger-Class
*/
function log($var, $level = LOG_DEBUG) {
- $_this = Debugger::getInstance();
+ $_this =& Debugger::getInstance();
$source = $_this->trace(array('start' => 1)) . "\n";
CakeLog::write($level, "\n" . $source . $_this->exportVar($var));
}
@@ -249,7 +249,7 @@ function handleError($code, $description, $file = null, $line = null, $context =
return;
}
- $_this = Debugger::getInstance();
+ $_this =& Debugger::getInstance();
if (empty($file)) {
$file = '[internal]';
@@ -327,7 +327,7 @@ function handleError($code, $description, $file = null, $line = null, $context =
* @link http://book.cakephp.org/view/460/Using-the-Debugger-Class
*/
function trace($options = array()) {
- $_this = Debugger::getInstance();
+ $_this =& Debugger::getInstance();
$defaults = array(
'depth' => 999,
'format' => $_this->_outputFormat,
@@ -472,7 +472,7 @@ function excerpt($file, $line, $context = 2) {
* @link http://book.cakephp.org/view/460/Using-the-Debugger-Class
*/
function exportVar($var, $recursion = 0) {
- $_this = Debugger::getInstance();
+ $_this =& Debugger::getInstance();
switch (strtolower(gettype($var))) {
case 'boolean':
return ($var) ? 'true' : 'false';
@@ -556,7 +556,7 @@ function __object($var) {
* @access protected
*/
function output($format = null, $strings = array()) {
- $_this = Debugger::getInstance();
+ $_this =& Debugger::getInstance();
$data = null;
if (is_null($format)) {
View
28 cake/tests/cases/libs/debugger.test.php
@@ -117,19 +117,19 @@ function testOutput() {
$result = Debugger::output(true);
$this->assertEqual($result[0]['error'], 'Notice');
- $this->assertEqual($result[0]['description'], 'Undefined variable: out');
- $this->assertPattern('/DebuggerTest::testOutput/', $result[0]['trace']);
- $this->assertPattern('/SimpleInvoker::invoke/', $result[0]['trace']);
+ $this->assertPattern('/Undefined variable\:\s+out/', $result[0]['description']);
+ $this->assertPattern('/DebuggerTest::testOutput/i', $result[0]['trace']);
+ $this->assertPattern('/SimpleInvoker::invoke/i', $result[0]['trace']);
ob_start();
Debugger::output('txt');
$other .= '';
$result = ob_get_clean();
- $this->assertPattern('/Undefined variable: other/', $result);
+ $this->assertPattern('/Undefined variable:\s+other/', $result);
$this->assertPattern('/Context:/', $result);
- $this->assertPattern('/DebuggerTest::testOutput/', $result);
- $this->assertPattern('/SimpleInvoker::invoke/', $result);
+ $this->assertPattern('/DebuggerTest::testOutput/i', $result);
+ $this->assertPattern('/SimpleInvoker::invoke/i', $result);
ob_start();
Debugger::output('html');
@@ -137,7 +137,7 @@ function testOutput() {
$result = ob_get_clean();
$this->assertPattern('/<pre class="cake-debug">.+<\/pre>/', $result);
$this->assertPattern('/<b>Notice<\/b>/', $result);
- $this->assertPattern('/variable: wrong/', $result);
+ $this->assertPattern('/variable:\s+wrong/', $result);
ob_start();
Debugger::output('js');
@@ -154,7 +154,7 @@ function testOutput() {
'b' => array(), 'Notice', '/b', ' (8)',
));
- $this->assertPattern('/Undefined variable: buzz/', $result[1]);
+ $this->assertPattern('/Undefined variable:\s+buzz/', $result[1]);
$this->assertPattern('/<a[^>]+>Code/', $result[1]);
$this->assertPattern('/<a[^>]+>Context/', $result[2]);
set_error_handler('simpleTestErrorHandler');
@@ -185,14 +185,14 @@ function testChangeOutputFormats() {
ob_start();
$foo .= '';
$result = ob_get_clean();
- set_error_handler('simpleTestErrorHandler');
+ set_error_handler('SimpleTestErrorHandler');
$data = array(
'error' => array(),
'code' => array(), '8', '/code',
'file' => array(), 'preg:/[^<]+/', '/file',
'line' => array(), '' . (intval(__LINE__) + -8), '/line',
- 'Undefined variable: foo',
+ 'preg:/Undefined variable:\s+foo/',
'/error'
);
$this->assertTags($result, $data, true);
@@ -255,8 +255,8 @@ function testExportVar() {
View::$__scripts = array
View::$__paths = array
View::$webroot = NULL';
- $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
- $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
+ $result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result));
+ $expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected));
$this->assertEqual($result, $expected);
}
@@ -273,14 +273,14 @@ function testLog() {
Debugger::log('cool');
$result = file_get_contents(LOGS . 'debug.log');
- $this->assertPattern('/DebuggerTest\:\:testLog/', $result);
+ $this->assertPattern('/DebuggerTest\:\:testLog/i', $result);
$this->assertPattern('/"cool"/', $result);
unlink(TMP . 'logs' . DS . 'debug.log');
Debugger::log(array('whatever', 'here'));
$result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
- $this->assertPattern('/DebuggerTest\:\:testLog/', $result);
+ $this->assertPattern('/DebuggerTest\:\:testLog/i', $result);
$this->assertPattern('/\[main\]/', $result);
$this->assertPattern('/array/', $result);
$this->assertPattern('/"whatever",/', $result);

0 comments on commit d4d9ed7

Please sign in to comment.
Something went wrong with that request. Please try again.