mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding tests for Debugger::addFormat()
This commit is contained in:
parent
73f4b8c8bf
commit
48c6b78660
1 changed files with 39 additions and 0 deletions
|
@ -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} - <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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue