]> git.mjollnir.org Git - moodle.git/commitdiff
unit tests: MDL-17803 test classes were not getting destroyed at the right time,...
authortjhunt <tjhunt>
Wed, 7 Jan 2009 08:58:41 +0000 (08:58 +0000)
committertjhunt <tjhunt>
Wed, 7 Jan 2009 08:58:41 +0000 (08:58 +0000)
lib/simpletestlib/moodle_readme.txt [new file with mode: 0644]
lib/simpletestlib/simpletest.php
lib/simpletestlib/test_case.php

diff --git a/lib/simpletestlib/moodle_readme.txt b/lib/simpletestlib/moodle_readme.txt
new file mode 100644 (file)
index 0000000..bcf051e
--- /dev/null
@@ -0,0 +1,10 @@
+Description of SimpleTest Version: 1.0.1 library import
+
+Obtained from http://www.simpletest.org/en/download.html
+
+Moodle-specific changes:
+* Bug fix in simpletest.php and test_case.php. Marked with //moodlefix begins,
+  //moodlefix ends comments. This has been reported back to the simpletest mailing
+  list. Hopefully will be included in a future release.
+
+Tim.
\ No newline at end of file
index e63e57464626b403b764a2026689c9739a9e172c..1581fbf6123f6f1664c64ae0720ff88f63f1d30a 100644 (file)
@@ -276,6 +276,19 @@ class SimpleTestContext {
         $this->_test = &$test;
     }
 
+//moodlefix begins
+    /**
+     *    Unsets the current test case instance. Avoids
+     *    problems when test classes rely on their destructors
+     *    being called at a predictable time.
+     *    @access public
+     */
+    function unsetTest() {
+        $this->clear();
+        $this->_test = NULL;
+    }
+
+//moodlefix ends
     /**
      *    Accessor for currently running test case.
      *    @return SimpleTestCase    Current test.
index ae27c8b255811a48797307e459b939e77e2ae11f..48aee9621bbda677f50926febde53b6b2ac11f25 100644 (file)
@@ -148,6 +148,9 @@ class SimpleTestCase {
             $reporter->paintCaseEnd($this->getLabel());
         }
         unset($this->_reporter);
+//moodlefix begins
+        $context->unsetTest();
+//moodlefix ends
         return $reporter->getStatus();
     }