Permalink
Browse files

Fix string '0' not being exported correctly.

Fixes #3518
  • Loading branch information...
markstory committed Jan 10, 2013
1 parent 735517a commit 7008b812be45c2f3fc41b90e6485fd22178271ff
Showing with 27 additions and 1 deletion.
  1. +26 −0 lib/Cake/Test/Case/Utility/DebuggerTest.php
  2. +1 −1 lib/Cake/Utility/Debugger.php
@@ -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
*
@@ -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 . "'";

0 comments on commit 7008b81

Please sign in to comment.