Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 14dac82376d315d9007453ca93a62e36ce8ee172 1 parent 06ede85
@timhunt timhunt authored stronk7 committed
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/dml/simpletest/testdml.php
View
20 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() {
Please sign in to comment.
Something went wrong with that request. Please try again.