]> git.mjollnir.org Git - moodle.git/commitdiff
Fix one test failing depending of the debug/debugdisplay settings.
authorstronk7 <stronk7>
Tue, 23 Jun 2009 00:24:52 +0000 (00:24 +0000)
committerstronk7 <stronk7>
Tue, 23 Jun 2009 00:24:52 +0000 (00:24 +0000)
lib/dml/simpletest/testdml.php

index fa9fe15965602f5b9659efb8aab90b79f5b67037..d0d4cfa6563995668d7a1736f4f0b13ffb40daa1 100755 (executable)
@@ -12,6 +12,8 @@ class dml_test extends UnitTestCase {
     private $tables = array();
     private $tdb;
     private $data;
+    public  static $includecoverage = array('lib/dml');
+    public  static $excludecoverage = array('lib/dml/simpletest');
 
     function setUp() {
         global $CFG, $DB, $UNITTEST;
@@ -737,6 +739,7 @@ class dml_test extends UnitTestCase {
     }
 
     public function test_get_records_sql() {
+        global $CFG;
         $DB = $this->tdb;
         $dbman = $DB->get_manager();
 
@@ -759,13 +762,21 @@ class dml_test extends UnitTestCase {
         $this->assertEqual(1, reset($records)->id);
         $this->assertEqual(2, next($records)->id);
 
+        // Awful test, requires debug enabled and sent to browser. Let's do that and restore after test
+        $olddebug   = $CFG->debug;       // Save current debug settings
+        $olddisplay = $CFG->debugdisplay;
+        $CFG->debug = DEBUG_DEVELOPER;
+        $CFG->debugdisplay = true;
         ob_start(); // hide debug warning
         $records = $DB->get_records_sql("SELECT course AS id, course AS course FROM {".$tablename."}", null);
-        $debuginfo = ob_get_contents();
+        $CFG->debug = $olddebug;         // Restore original debug settings
         ob_end_clean();
+        $CFG->debugdisplay = $olddisplay;
+        $debuginfo = ob_get_contents();
 
         $this->assertEqual(3, count($records));
         $this->assertFalse($debuginfo === '');
+        print_object($debuginfo);
     }
 
     public function test_get_records_menu() {