Skip to content
This repository
Browse code

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...
commit 0a182b918f2c3c61b6f0e8dc3c79bdaf0223c842 1 parent 454fae9
Mark Story authored June 10, 2012
21  lib/Cake/Test/Case/Utility/DebuggerTest.php
@@ -345,6 +345,21 @@ public function testExportVar() {
345 345
 )
346 346
 TEXT;
347 347
 		$this->assertTextEquals($expected, $result);
  348
+
  349
+		$data = array(
  350
+			'key' => array(
  351
+				'value'
  352
+			)
  353
+		);
  354
+		$result = Debugger::exportVar($data, 1);
  355
+		$expected = <<<TEXT
  356
+array(
  357
+	'key' => array(
  358
+		[maximum depth reached]
  359
+	)
  360
+)
  361
+TEXT;
  362
+		$this->assertTextEquals($expected, $result);
348 363
 	}
349 364
 
350 365
 /**
@@ -398,8 +413,14 @@ public function testDump() {
398 413
 <pre>array(
399 414
 	'People' => array(
400 415
 		(int) 0 => array(
  416
+			'name' => 'joeseph',
  417
+			'coat' => 'technicolor',
  418
+			'hair_color' => 'brown'
401 419
 		),
402 420
 		(int) 1 => array(
  421
+			'name' => 'Shaft',
  422
+			'coat' => 'black',
  423
+			'hair' => 'black'
403 424
 		)
404 425
 	)
405 426
 )</pre>
4  lib/Cake/Utility/Debugger.php
@@ -544,8 +544,10 @@ protected static function _array(array $var, $depth, $indent) {
544 544
 			foreach ($var as $key => $val) {
545 545
 				$vars[] = $break . self::exportVar($key) .
546 546
 					' => ' .
547  
-					self::_export($val, $depth - 1, $indent);
  547
+					self::_export($val, $depth, $indent);
548 548
 			}
  549
+		} else {
  550
+			$vars[] = $break . '[maximum depth reached]';
549 551
 		}
550 552
 		return $out . implode(',', $vars) . $end . ')';
551 553
 	}

0 notes on commit 0a182b9

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