Skip to content

Commit

Permalink
Adding tests for Debugger::addFormat()
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 23, 2011
1 parent 73f4b8c commit 48c6b78
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lib/Cake/Test/Case/Utility/DebuggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,45 @@ public function testOutputAsException() {
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} - <a href="txmt://open?url=file://{:file}' .
'&line={:line}">{:path}</a>, line {:line}'
));
Debugger::outputAs('js');

$result = Debugger::trace();
$this->assertPattern('/' . preg_quote('txmt://open?url=file://', '/') . '(\/|[A-Z]:\\\\)' . '/', $result);

Debugger::addFormat('xml', array(
'error' => '<error><code>{:code}</code><file>{:file}</file><line>{:line}</line>' .
'{:description}</error>',
));
Debugger::outputAs('xml');

ob_start();
$foo .= '';
$result = ob_get_clean();

$data = array(
'<error',
'<code', '8', '/code',
'<file', 'preg:/[^<]+/', '/file',
'<line', '' . (intval(__LINE__) - 7), '/line',
'preg:/Undefined variable:\s+foo/',
'/error'
);
$this->assertTags($result, $data, true);
}

/**
* testTrimPath method
*
Expand Down

0 comments on commit 48c6b78

Please sign in to comment.