Skip to content

Commit

Permalink
Adding test for using __debugInfo in Debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 8, 2014
1 parent c257263 commit f7b0912
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/TestCase/Utility/DebuggerTest.php
Expand Up @@ -28,6 +28,14 @@
class DebuggerTestCaseDebugger extends Debugger {
}

class DebuggableThing {

public function __debugInfo() {
return ['foo' => 'bar', 'inner' => new self()];
}

}

/**
* DebuggerTest class
*
Expand Down Expand Up @@ -623,4 +631,28 @@ public function testTraceExclude() {
));
$this->assertNotRegExp('/^Cake\\\Test\\\TestCase\\\Utility\\\DebuggerTest::testTraceExclude/', $result);
}

/**
* Tests that __debugInfo is used when available
*
* @return void
*/
public function testDebugInfo() {
$object = new DebuggableThing();
$result = Debugger::exportVar($object, 2);
$expected =<<<eos
object(Cake\Test\TestCase\Utility\DebuggableThing) {
'foo' => 'bar',
'inner' => object(Cake\Test\TestCase\Utility\DebuggableThing) {
[maximum depth reached]
}
}
eos;
$this->assertEquals($expected, $result);
}

}

0 comments on commit f7b0912

Please sign in to comment.