Skip to content
Permalink
Browse files

Fix $depth being decremented by 2.

$depth should only be decremented once for each step-in.
Add special text when values are being elided by maximum nesting level.

Fixes #2946
  • Loading branch information...
markstory committed Jun 11, 2012
1 parent 454fae9 commit 0a182b918f2c3c61b6f0e8dc3c79bdaf0223c842
Showing with 24 additions and 1 deletion.
  1. +21 −0 lib/Cake/Test/Case/Utility/DebuggerTest.php
  2. +3 −1 lib/Cake/Utility/Debugger.php
@@ -343,6 +343,21 @@ public function testExportVar() {
(int) 1 => 'Index one',
(int) 5 => 'Index five'
)
TEXT;
$this->assertTextEquals($expected, $result);
$data = array(
'key' => array(
'value'
)
);
$result = Debugger::exportVar($data, 1);
$expected = <<<TEXT
array(
'key' => array(
[maximum depth reached]
)
)
TEXT;
$this->assertTextEquals($expected, $result);
}
@@ -398,8 +413,14 @@ public function testDump() {
<pre>array(
'People' => array(
(int) 0 => array(
'name' => 'joeseph',
'coat' => 'technicolor',
'hair_color' => 'brown'
),
(int) 1 => array(
'name' => 'Shaft',
'coat' => 'black',
'hair' => 'black'
)
)
)</pre>
@@ -544,8 +544,10 @@ protected static function _array(array $var, $depth, $indent) {
foreach ($var as $key => $val) {
$vars[] = $break . self::exportVar($key) .
' => ' .
self::_export($val, $depth - 1, $indent);
self::_export($val, $depth, $indent);
}
} else {
$vars[] = $break . '[maximum depth reached]';
}
return $out . implode(',', $vars) . $end . ')';
}

0 comments on commit 0a182b9

Please sign in to comment.
You can’t perform that action at this time.