Permalink
Browse files

MDL-27325 New DB unit tests to demonstrate the problem.

  • Loading branch information...
1 parent 06ede85 commit 14dac82376d315d9007453ca93a62e36ce8ee172 @timhunt timhunt committed with stronk7 Apr 29, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/dml/simpletest/testdml.php
@@ -1726,6 +1726,26 @@ public function test_insert_record() {
$DB->delete_records($tablename, array());
$id4 = $DB->insert_record($tablename, array('course' => 3));
$this->assertTrue($id3 < $id4);
+
+ // Test saving a float in a CHAR column, and reading it back.
+ $id = $DB->insert_record($tablename, array('onechar' => 1.0));
+ $this->assertEqual(1.0, $DB->get_field($tablename, 'onechar', array('id' => $id)));
+ $id = $DB->insert_record($tablename, array('onechar' => 1e20));
+ $this->assertEqual(1e20, $DB->get_field($tablename, 'onechar', array('id' => $id)));
+ $id = $DB->insert_record($tablename, array('onechar' => 1e-4));
+ $this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
+ $id = $DB->insert_record($tablename, array('onechar' => 1e-5));
+ $this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
+
+ // Test saving a float in a TEXT column, and reading it back.
+ $id = $DB->insert_record($tablename, array('onetext' => 1.0));
+ $this->assertEqual(1.0, $DB->get_field($tablename, 'onetext', array('id' => $id)));
+ $id = $DB->insert_record($tablename, array('onetext' => 1e20));
+ $this->assertEqual(1e20, $DB->get_field($tablename, 'onetext', array('id' => $id)));
+ $id = $DB->insert_record($tablename, array('onetext' => 1e-4));
+ $this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
+ $id = $DB->insert_record($tablename, array('onetext' => 1e-5));
+ $this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
}
public function test_import_record() {

0 comments on commit 14dac82

Please sign in to comment.