Permalink
Browse files

Adding test cases for using localized floats with mysql. Also added a…

… generic model test case. Refs #1029
  • Loading branch information...
1 parent e23fe25 commit afc05c1e050869b20e85be87ac3d378c146b9a52 @markstory markstory committed Aug 21, 2010
@@ -278,6 +278,24 @@ function testQuoting() {
}
/**
+ * 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.141593);
+ $this->assertEqual((string)$result, '3.141593');
+
+ setlocale(LC_ALL, $restore);
+ }
+
+/**
* testTinyintCasting method
*
* @access public
@@ -3880,4 +3880,22 @@ function testSaveAllEmptyData() {
$this->assertFalse($result);
}
+/**
+ * test writing floats in german locale.
+ *
+ * @return void
+ */
+ function testWriteFloatAsGerman() {
+ $restore = setlocale(LC_ALL, null);
+ setlocale(LC_ALL, 'de_DE');
+
+ $model = new DataTest();
+ $result = $model->save(array(
+ 'count' => 1,
+ 'float' => 3.14593
+ ));
+ $this->assertTrue($result);
+ setlocale(LC_ALL, $restore);
+ }
+
}

0 comments on commit afc05c1

Please sign in to comment.