From eb96d8acfbe6c31230fb28f21110aaec5de57eaf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Aug 2010 00:39:45 -0400 Subject: [PATCH] Adding tests to dbo_postgres for localized floats. Refs #1029 --- .../datasources/dbo/dbo_postgres.test.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index ad7b3166b..3fd70d1db 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -352,7 +352,7 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testValueQuoting() { - $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.2'"); + $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.200000'"); $this->assertEqual($this->db2->value('1,2', 'float'), "'1,2'"); $this->assertEqual($this->db2->value('0', 'integer'), "'0'"); @@ -378,6 +378,24 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->db2->value(array()), "NULL"); } +/** + * test that localized floats don't cause trouble. + * + * @return void + */ + function testLocalizedFloats() { + $restore = setlocale(LC_ALL, null); + setlocale(LC_ALL, 'de_DE'); + + $result = $this->db->value(3.141593, 'float'); + $this->assertEqual((string)$result, "'3.141593'"); + + $result = $this->db->value(3.14); + $this->assertEqual((string)$result, "'3.140000'"); + + setlocale(LC_ALL, $restore); + } + /** * test that date and time columns do not generate errors with null and nullish values. *