Skip to content

Commit

Permalink
Fix string '0' not being exported correctly.
Browse files Browse the repository at this point in the history
Fixes #3518
  • Loading branch information
markstory committed Jan 10, 2013
1 parent 735517a commit 7008b81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions lib/Cake/Test/Case/Utility/DebuggerTest.php
Expand Up @@ -408,6 +408,32 @@ public function testExportVar() {
$this->assertTextEquals($expected, $result);
}

/**
* Test exporting various kinds of false.
*
* @return void
*/
public function testExportVarZero() {
$data = array(
'nothing' => '',
'null' => null,
'false' => false,
'szero' => '0',
'zero' => 0
);;
$result = Debugger::exportVar($data);
$expected = <<<TEXT
array(
'nothing' => '',
'null' => null,
'false' => false,
'szero' => '0',
'zero' => (int) 0
)
TEXT;
$this->assertTextEquals($expected, $result);
}

/**
* testLog method
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Debugger.php
Expand Up @@ -489,7 +489,7 @@ protected static function _export($var, $depth, $indent) {
case 'float':
return '(float) ' . $var;
case 'string':
if (!trim($var)) {
if (trim($var) === '') {
return "''";
}
return "'" . $var . "'";
Expand Down

0 comments on commit 7008b81

Please sign in to comment.