Skip to content

Commit eb96d8a

Browse files
committed
Adding tests to dbo_postgres for localized floats. Refs #1029
1 parent afc05c1 commit eb96d8a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function testColumnParsing() {
352352
* @return void
353353
*/
354354
function testValueQuoting() {
355-
$this->assertIdentical($this->db2->value(1.2, 'float'), "'1.2'");
355+
$this->assertIdentical($this->db2->value(1.2, 'float'), "'1.200000'");
356356
$this->assertEqual($this->db2->value('1,2', 'float'), "'1,2'");
357357

358358
$this->assertEqual($this->db2->value('0', 'integer'), "'0'");
@@ -378,6 +378,24 @@ function testValueQuoting() {
378378
$this->assertEqual($this->db2->value(array()), "NULL");
379379
}
380380

381+
/**
382+
* test that localized floats don't cause trouble.
383+
*
384+
* @return void
385+
*/
386+
function testLocalizedFloats() {
387+
$restore = setlocale(LC_ALL, null);
388+
setlocale(LC_ALL, 'de_DE');
389+
390+
$result = $this->db->value(3.141593, 'float');
391+
$this->assertEqual((string)$result, "'3.141593'");
392+
393+
$result = $this->db->value(3.14);
394+
$this->assertEqual((string)$result, "'3.140000'");
395+
396+
setlocale(LC_ALL, $restore);
397+
}
398+
381399
/**
382400
* test that date and time columns do not generate errors with null and nullish values.
383401
*

0 commit comments

Comments
 (0)