MDL-40388 Reset globals after each unit test
This commit is contained in:
committed by
Damyon Wiese
parent
d4bbe8997f
commit
161d67d8df
@@ -160,6 +160,10 @@ class phpunit_util extends testing_util {
|
||||
$_SERVER = self::get_global_backup('_SERVER');
|
||||
$CFG = self::get_global_backup('CFG');
|
||||
$SITE = self::get_global_backup('SITE');
|
||||
$_GET = array();
|
||||
$_POST = array();
|
||||
$_FILES = array();
|
||||
$_REQUEST = array();
|
||||
$COURSE = $SITE;
|
||||
|
||||
// reinitialise following globals
|
||||
|
||||
@@ -219,6 +219,28 @@ class core_phpunit_advanced_testcase extends advanced_testcase {
|
||||
$this->assertTrue(isset($CFG->admin));
|
||||
$this->assertEquals(1, $CFG->rolesactive);
|
||||
|
||||
// _GET change.
|
||||
$_GET['__somethingthatwillnotnormallybepresent__'] = 'yy';
|
||||
phpunit_util::reset_all_data(true);
|
||||
|
||||
$this->assertEquals(array(), $_GET);
|
||||
|
||||
|
||||
// _POST change.
|
||||
$_POST['__somethingthatwillnotnormallybepresent2__'] = 'yy';
|
||||
phpunit_util::reset_all_data(true);
|
||||
$this->assertEquals(array(), $_POST);
|
||||
|
||||
// _FILES change.
|
||||
$_FILES['__somethingthatwillnotnormallybepresent3__'] = 'yy';
|
||||
phpunit_util::reset_all_data(true);
|
||||
$this->assertEquals(array(), $_FILES);
|
||||
|
||||
// _REQUEST change.
|
||||
$_REQUEST['__somethingthatwillnotnormallybepresent4__'] = 'yy';
|
||||
phpunit_util::reset_all_data(true);
|
||||
$this->assertEquals(array(), $_REQUEST);
|
||||
|
||||
//silent changes
|
||||
$_SERVER['xx'] = 'yy';
|
||||
phpunit_util::reset_all_data(true);
|
||||
|
||||
Reference in New Issue
Block a user