Permalink
Browse files

MDL-34130 fix data inserts in recordset tests

  • Loading branch information...
1 parent a5f6ea2 commit 9ee97228bdf1d7c658fe470a7d92a4221104addf @skodak skodak committed Jul 1, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/dml/tests/dml_test.php
View
@@ -921,12 +921,12 @@ public function test_get_recordset() {
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$dbman->create_table($table);
- $data = array(array('id' => 1, 'course' => 3, 'name' => 'record1', 'onetext'=>'abc'),
- array('id' => 2, 'course' => 3, 'name' => 'record2', 'onetext'=>'abcd'),
- array('id' => 3, 'course' => 5, 'name' => 'record3', 'onetext'=>'abcde'));
+ $data = array(array('course' => 3, 'name' => 'record1', 'onetext'=>'abc'),
+ array('course' => 3, 'name' => 'record2', 'onetext'=>'abcd'),
+ array('course' => 5, 'name' => 'record3', 'onetext'=>'abcde'));
- foreach ($data as $record) {
- $DB->insert_record($tablename, $record);
+ foreach ($data as $key=>$record) {
+ $data[$key]['id'] = $DB->insert_record($tablename, $record);
}
// standard recordset iteration
@@ -1009,11 +1009,11 @@ public function test_get_recordset_iterator_keys() {
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$dbman->create_table($table);
- $data = array(array('id'=> 1, 'course' => 3, 'name' => 'record1'),
- array('id'=> 2, 'course' => 3, 'name' => 'record2'),
- array('id'=> 3, 'course' => 5, 'name' => 'record3'));
- foreach ($data as $record) {
- $DB->insert_record($tablename, $record);
+ $data = array(array('course' => 3, 'name' => 'record1'),
+ array('course' => 3, 'name' => 'record2'),
+ array('course' => 5, 'name' => 'record3'));
+ foreach ($data as $key=>$record) {
+ $data[$key]['id'] = $DB->insert_record($tablename, $record);
}
// Test repeated numeric keys are returned ok

0 comments on commit 9ee9722

Please sign in to comment.