From 48c6b78660f48782a0a175f50fdb89574fbad2d9 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 21 Aug 2011 10:30:10 -0400 Subject: [PATCH] Adding tests for Debugger::addFormat() --- lib/Cake/Test/Case/Utility/DebuggerTest.php | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index dd8f975af..8ff8e399b 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -216,6 +216,45 @@ class DebuggerTest extends CakeTestCase { Debugger::outputAs('Invalid junk'); } +/** + * Tests that changes in output formats using Debugger::output() change the templates used. + * + * @return void + */ + public function testAddFormat() { + set_error_handler('Debugger::showError'); + $this->_restoreError = true; + + Debugger::addFormat('js', array( + 'traceLine' => '{:reference} - {:path}, line {:line}' + )); + Debugger::outputAs('js'); + + $result = Debugger::trace(); + $this->assertPattern('/' . preg_quote('txmt://open?url=file://', '/') . '(\/|[A-Z]:\\\\)' . '/', $result); + + Debugger::addFormat('xml', array( + 'error' => '{:code}{:file}{:line}' . + '{:description}', + )); + Debugger::outputAs('xml'); + + ob_start(); + $foo .= ''; + $result = ob_get_clean(); + + $data = array( + 'assertTags($result, $data, true); + } + /** * testTrimPath method *