mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Adding tests for Debugger::outputAs()
Adding exceptions for invalid state checking.
This commit is contained in:
parent
35fc8352ce
commit
daf1251473
2 changed files with 27 additions and 3 deletions
|
@ -196,6 +196,26 @@ class DebuggerTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $data, true);
|
$this->assertTags($result, $data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that outputAs works.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testOutputAs() {
|
||||||
|
Debugger::outputAs('html');
|
||||||
|
$this->assertEquals('html', Debugger::outputAs());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that choosing a non-existant format causes an exception
|
||||||
|
*
|
||||||
|
* @expectedException CakeException
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testOutputAsException() {
|
||||||
|
Debugger::outputAs('Invalid junk');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testTrimPath method
|
* testTrimPath method
|
||||||
*
|
*
|
||||||
|
|
|
@ -93,7 +93,8 @@ class Debugger {
|
||||||
),
|
),
|
||||||
'base' => array(
|
'base' => array(
|
||||||
'traceLine' => '{:reference} - {:path}, line {:line}'
|
'traceLine' => '{:reference} - {:path}, line {:line}'
|
||||||
)
|
),
|
||||||
|
'log' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -558,13 +559,17 @@ class Debugger {
|
||||||
*
|
*
|
||||||
* @param string $format The format you want errors to be output as.
|
* @param string $format The format you want errors to be output as.
|
||||||
* Leave null to get the current format.
|
* Leave null to get the current format.
|
||||||
* @return void
|
* @return mixed Returns null when setting. Returns the current format when getting.
|
||||||
|
* @throws CakeException when choosing a format that doesn't exist.
|
||||||
*/
|
*/
|
||||||
public static function outputAs($format = null) {
|
public static function outputAs($format = null) {
|
||||||
$self = Debugger::getInstance();
|
$self = Debugger::getInstance();
|
||||||
if ($format === null) {
|
if ($format === null) {
|
||||||
return $self->_outputFormat;
|
return $self->_outputFormat;
|
||||||
}
|
}
|
||||||
|
if ($format !== false && !isset($self->_templates[$format])) {
|
||||||
|
throw new CakeException(__d('cake_dev', 'Invalid Debugger output format.'));
|
||||||
|
}
|
||||||
$self->_outputFormat = $format;
|
$self->_outputFormat = $format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +646,6 @@ class Debugger {
|
||||||
$format = false;
|
$format = false;
|
||||||
}
|
}
|
||||||
Debugger::outputAs($format);
|
Debugger::outputAs($format);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue