MDL-23568 new unit test that verifies the id is not modified in isnert_record() methods
authorPetr Skoda <skodak@moodle.org>
Sat, 31 Jul 2010 21:13:46 +0000 (21:13 +0000)
committerPetr Skoda <skodak@moodle.org>
Sat, 31 Jul 2010 21:13:46 +0000 (21:13 +0000)
lib/dml/simpletest/testdml.php

index 1d02140..d0110bd 100755 (executable)
@@ -1342,6 +1342,15 @@ class dml_test extends UnitTestCase {
         $this->assertEqual($newclob, $record->onetext, 'Test "small" CLOB insert (full contents output disabled)');
         $this->assertEqual($newblob, $record->onebinary, 'Test "small" BLOB insert (full contents output disabled)');
         $this->assertEqual(false, $rs->key()); // Ensure recordset key() method to be working ok after closing
         $this->assertEqual($newclob, $record->onetext, 'Test "small" CLOB insert (full contents output disabled)');
         $this->assertEqual($newblob, $record->onebinary, 'Test "small" BLOB insert (full contents output disabled)');
         $this->assertEqual(false, $rs->key()); // Ensure recordset key() method to be working ok after closing
+
+        // test data is not modified
+        $rec = new object();
+        $rec->id     = -1; // has to be ignored
+        $rec->course = 3;
+        $rec->lalala = 'lalal'; // unused
+        $before = clone($rec);
+        $DB->insert_record($tablename, $record);
+        $this->assertEqual($rec, $before);
     }
 
     public function test_import_record() {
     }
 
     public function test_import_record() {