MDL-14081 fixed error in eventslib unit tests

This commit is contained in:
nicolasconnault 2008-09-06 11:22:30 +00:00
parent 6e73ac4214
commit 7399a49d44
2 changed files with 11 additions and 3 deletions

View 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);

View File

@ -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'));