From: tjhunt Date: Wed, 7 Jan 2009 08:58:41 +0000 (+0000) Subject: unit tests: MDL-17803 test classes were not getting destroyed at the right time,... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a7b7f075df892c9044937fe6544b7ac234bcbfa1;p=moodle.git unit tests: MDL-17803 test classes were not getting destroyed at the right time, which was breaking the code that reset the test DB to the normal DB. --- diff --git a/lib/simpletestlib/moodle_readme.txt b/lib/simpletestlib/moodle_readme.txt new file mode 100644 index 0000000000..bcf051e030 --- /dev/null +++ b/lib/simpletestlib/moodle_readme.txt @@ -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 diff --git a/lib/simpletestlib/simpletest.php b/lib/simpletestlib/simpletest.php index e63e574646..1581fbf612 100644 --- a/lib/simpletestlib/simpletest.php +++ b/lib/simpletestlib/simpletest.php @@ -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. diff --git a/lib/simpletestlib/test_case.php b/lib/simpletestlib/test_case.php index ae27c8b255..48aee9621b 100644 --- a/lib/simpletestlib/test_case.php +++ b/lib/simpletestlib/test_case.php @@ -148,6 +148,9 @@ class SimpleTestCase { $reporter->paintCaseEnd($this->getLabel()); } unset($this->_reporter); +//moodlefix begins + $context->unsetTest(); +//moodlefix ends return $reporter->getStatus(); }