From 7399a49d44d43ec3008ff8ff0fa8d6aa59fc36be Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Sat, 6 Sep 2008 11:22:30 +0000 Subject: [PATCH] MDL-14081 fixed error in eventslib unit tests --- .../test_postgres7_adodb_moodle_database.php | 2 -- lib/simpletest/testeventslib.php | 12 +++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/dml/simpletest/test_postgres7_adodb_moodle_database.php b/lib/dml/simpletest/test_postgres7_adodb_moodle_database.php index 367dc1e6a89..115b549ff66 100644 --- a/lib/dml/simpletest/test_postgres7_adodb_moodle_database.php +++ b/lib/dml/simpletest/test_postgres7_adodb_moodle_database.php @@ -13,8 +13,6 @@ class postgres7_adodb_moodle_database_test extends dbspecific_test { function test_ilike() { $DB = $this->tdb; - $id = $DB->insert_record('testtable', array('name' => 'SuperDuperREcord')); - $sql = "SELECT 'SuperDuperRecord' " . $DB->sql_ilike() . " '%per%' AS result"; $record = $DB->get_record_sql($sql); $this->assertEqual('t', $record->result); diff --git a/lib/simpletest/testeventslib.php b/lib/simpletest/testeventslib.php index efb002718f2..177eebe189f 100755 --- a/lib/simpletest/testeventslib.php +++ b/lib/simpletest/testeventslib.php @@ -75,7 +75,7 @@ class sample_handler_class { } class eventslib_test extends UnitTestCase { - + private $realdb; /** * Create temporary entries in the database for these tests. * These tests have to work no matter the data currently in the database @@ -83,6 +83,15 @@ class eventslib_test extends UnitTestCase { * data have to be artificially inseminated (:-) in the DB. */ function setUp() { + // Set global category settings to -1 (not force) + global $CFG, $DB; + + if (is_null($DB)) { + $this->realdb = $DB; + $DB = moodle_database::get_driver_instance($CFG->dbtype, $CFG->dblibrary); + $DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->dbpersist, $CFG->prefix); + } + events_uninstall('unittest'); sample_function_handler('reset'); sample_handler_class::static_method('reset'); @@ -123,6 +132,7 @@ class eventslib_test extends UnitTestCase { * Tests the update of event handlers from file */ function test__events_update_definition__update() { + global $DB; // first modify directly existing handler $handler = $DB->get_record('events_handlers', array('handlermodule'=>'unittest', 'eventname'=>'test_instant'));