]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14081 fixed error in eventslib unit tests
authornicolasconnault <nicolasconnault>
Sat, 6 Sep 2008 11:22:30 +0000 (11:22 +0000)
committernicolasconnault <nicolasconnault>
Sat, 6 Sep 2008 11:22:30 +0000 (11:22 +0000)
lib/dml/simpletest/test_postgres7_adodb_moodle_database.php
lib/simpletest/testeventslib.php

index 367dc1e6a89951f415b1d7ae38fbad8e6d1ab672..115b549ff66cfb054c509de730b659f513292985 100644 (file)
@@ -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);
index efb002718f25f8df8faca3a2ae782c74b1329653..177eebe189f562df4b100c1a424a0c5f3360d0cf 100755 (executable)
@@ -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'));