Skip to content

Commit

Permalink
MDL-19057 added hack for oracle testing (random oci bug) and some mis…
Browse files Browse the repository at this point in the history
…sing close() statements.
  • Loading branch information
stronk7 committed Sep 21, 2009
1 parent 8089f8f commit 515cb65
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/dml/simpletest/testdml.php
Expand Up @@ -47,15 +47,16 @@ function tearDown() {
* @return xmldb_table the table object.
*/
private function get_test_table($tablename="") {
$DB = $this->tdb;
$dbman = $this->tdb->get_manager();

if ($tablename === "") {
if (defined('OCI_HACKERY')) {
static $i = 0;
$tablename = "unit_table".$i++;
} else {
$tablename = "unit_table";
}
if ($tablename == '') {
if ($DB->get_dbfamily() == 'oracle') { // To avoid one strange (OCI internal schema cache?) bug causing ORA-01007 errors
static $i = 0; // if the same table is created multiple times and SELECT * are
$tablename = "unit_table".$i++; // executed against it. Curiously error doesn't happen if the query
} else { // specify the list of columns instead of *. Haven't found any logic cause
$tablename = "unit_table"; // for the problem in our code, just this workaround. Luckily this isn't a
} // problem in normal usage (same table being recreated once and again)
}

$table = new xmldb_table($tablename);
Expand Down Expand Up @@ -608,13 +609,15 @@ public function test_get_recordset_select() {
foreach ($rs as $record) {
$counter++;
}
$rs->close();
$this->assertEqual(4, $counter);

$this->assertTrue($rs = $DB->get_recordset_select($tablename, 'course = 3'));
$counter = 0;
foreach ($rs as $record) {
$counter++;
}
$rs->close();
$this->assertEqual(2, $counter);
}

Expand All @@ -641,6 +644,7 @@ public function test_get_recordset_sql() {
foreach ($rs as $record) {
$counter++;
}
$rs->close();
$this->assertEqual(2, $counter);
}

Expand Down

0 comments on commit 515cb65

Please sign in to comment.