MDL-47675 phpunit: Update unit tests to pass on MSSQL

Unit tests were failing on MSSQL. gc_collect_cycles() was
removed from the phpunit utils.php file to save time in running
the tests, but MSSQL doesn't clean up open files as well as
other databases.

This patch includes the garbage collection for the unit tests
that require it.
This commit is contained in:
Adrian Greeve 2014-10-20 14:21:53 +08:00
parent b49de5d930
commit c42d18183a
7 changed files with 49 additions and 0 deletions

View File

@ -35,6 +35,13 @@ global $CFG;
*/
class tool_uploadcourse_course_testcase extends advanced_testcase {
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
public function test_proceed_without_prepare() {
$this->resetAfterTest(true);
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;

View File

@ -36,6 +36,13 @@ require_once($CFG->libdir . '/csvlib.class.php');
*/
class tool_uploadcourse_processor_testcase extends advanced_testcase {
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
public function test_basic() {
global $DB;
$this->resetAfterTest(true);

View File

@ -38,6 +38,13 @@ require_once($CFG->libdir . '/completionlib.php');
*/
class core_backup_moodle2_testcase extends advanced_testcase {
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
/**
* Tests the availability field on modules and sections is correctly
* backed up and restored.

View File

@ -33,6 +33,13 @@ require_once($CFG->dirroot . '/tag/lib.php');
class core_course_courselib_testcase extends advanced_testcase {
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
/**
* Set forum specific test values for calling create_module().
*

View File

@ -47,6 +47,13 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
require_once($CFG->dirroot . '/course/externallib.php');
}
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
/**
* Test create_categories
*/

View File

@ -51,6 +51,13 @@ class core_questionlib_testcase extends advanced_testcase {
$this->resetAfterTest();
}
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
public function test_question_reorder_qtypes() {
$this->assertEquals(
array(0 => 't2', 1 => 't1', 2 => 't3'),

View File

@ -52,6 +52,13 @@ class assignfeedback_editpdf_testcase extends mod_assign_base_testcase {
parent::setUp();
}
/**
* Tidy up open files that may be left open.
*/
protected function tearDown() {
gc_collect_cycles();
}
protected function create_assign_and_submit_pdf() {
global $CFG;
$assign = $this->create_instance(array('assignsubmission_onlinetext_enabled' => 1,