From 541ca062f146b22cf667bd9629fd33bedccfa062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0koda?= Date: Sun, 1 Jul 2012 13:34:22 +0200 Subject: [PATCH] MDL-34130 test nested recordset iteration --- lib/dml/tests/dml_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index fcbffcefd3e..acecb7b27c0 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -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()