MDL-34130 test nested recordset iteration
authorPetr Škoda <commits@skodak.org>
Sun, 1 Jul 2012 11:34:22 +0000 (13:34 +0200)
committerPetr Škoda <commits@skodak.org>
Sun, 1 Jul 2012 19:40:36 +0000 (21:40 +0200)
lib/dml/tests/dml_test.php

index fcbffce..acecb7b 100644 (file)
@@ -990,6 +990,22 @@ class dml_testcase extends database_driver_testcase {
             $this->assertEquals($e->errorcode, 'textconditionsnotallowed');
         }
 
+        // Test nested iteration.
+        $rs1 = $DB->get_recordset($tablename);
+        $i = 0;
+        foreach($rs1 as $record1) {
+            $rs2 = $DB->get_recordset($tablename);
+            $i++;
+            $j = 0;
+            foreach($rs2 as $record2) {
+                $j++;
+            }
+            $rs2->close();
+            $this->assertEquals($j, count($data));
+        }
+        $rs1->close();
+        $this->assertEquals($i, count($data));
+
         // notes:
         //  * limits are tested in test_get_recordset_sql()
         //  * where_clause() is used internally and is tested in test_get_records()