mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Moved SINGLETON resetting for test runs from SiteTreeTest/ObjectTest into SapphireTest - there should be no caching between all test invocations to avoid side effects
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89893 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5ad33a014a
commit
11d5ce0274
@ -66,6 +66,11 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
SiteTree::reset();
|
||||
Controller::curr()->setSession(new Session(array()));
|
||||
|
||||
// clear singletons, they're caching old extension info
|
||||
// which is used in DatabaseAdmin->doBuild()
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
$className = get_class($this);
|
||||
$fixtureFile = eval("return {$className}::\$fixture_file;");
|
||||
|
||||
@ -223,6 +228,11 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
// clear singletons, they're caching old extension info
|
||||
// which is used in DatabaseAdmin->doBuild()
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
// Restore email configuration
|
||||
Email::set_mailer($this->originalMailer);
|
||||
$this->originalMailer = null;
|
||||
|
@ -79,9 +79,6 @@ class ObjectTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testStaticGetterMethod() {
|
||||
static $_SINGLETONS;
|
||||
$_SINGLETONS= null;
|
||||
|
||||
$obj = singleton('ObjectTest_MyObject');
|
||||
$this->assertEquals(
|
||||
ObjectTest_MyObject::$mystaticProperty,
|
||||
@ -91,9 +88,6 @@ class ObjectTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testStaticInheritanceGetters() {
|
||||
static $_SINGLETONS;
|
||||
$_SINGLETONS = null;
|
||||
|
||||
$obj = singleton('ObjectTest_MyObject');
|
||||
$subObj = singleton('ObjectTest_MyObject');
|
||||
$this->assertEquals(
|
||||
@ -104,9 +98,6 @@ class ObjectTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testStaticSettingOnSingletons() {
|
||||
static $_SINGLETONS;
|
||||
$_SINGLETONS = null;
|
||||
|
||||
$singleton1 = singleton('ObjectTest_MyObject');
|
||||
$singleton2 = singleton('ObjectTest_MyObject');
|
||||
$singleton1->set_stat('mystaticProperty', 'changed');
|
||||
@ -118,9 +109,6 @@ class ObjectTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testStaticSettingOnInstances() {
|
||||
static $_SINGLETONS;
|
||||
$_SINGLETONS = null;
|
||||
|
||||
$instance1 = new ObjectTest_MyObject();
|
||||
$instance2 = new ObjectTest_MyObject();
|
||||
$instance1->set_stat('mystaticProperty', 'changed');
|
||||
|
@ -26,10 +26,6 @@ class SiteTreeTest extends SapphireTest {
|
||||
if(self::$origTranslatableSettings['has_extension'])
|
||||
Object::remove_extension('SiteTree', 'Translatable');
|
||||
|
||||
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
// recreate database with new settings
|
||||
$dbname = self::create_temp_db();
|
||||
DB::set_alternative_database_name($dbname);
|
||||
@ -44,10 +40,6 @@ class SiteTreeTest extends SapphireTest {
|
||||
Translatable::set_default_locale(self::$origTranslatableSettings['default_locale']);
|
||||
Translatable::set_current_locale(self::$origTranslatableSettings['default_locale']);
|
||||
|
||||
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
self::kill_temp_db();
|
||||
self::create_temp_db();
|
||||
|
||||
|
@ -29,10 +29,6 @@ class TranslatableTest extends FunctionalTest {
|
||||
if(!self::$origTranslatableSettings['has_extension']) Object::add_extension('SiteTree', 'Translatable');
|
||||
Object::add_extension('TranslatableTest_DataObject', 'Translatable');
|
||||
|
||||
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
// recreate database with new settings
|
||||
$dbname = self::create_temp_db();
|
||||
DB::set_alternative_database_name($dbname);
|
||||
|
@ -29,10 +29,6 @@ class TranslatableSearchFormTest extends FunctionalTest {
|
||||
if(!self::$origTranslatableSettings['has_extension']) Object::add_extension('SiteTree', 'Translatable');
|
||||
Object::add_extension('TranslatableTest_DataObject', 'Translatable');
|
||||
|
||||
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
// recreate database with new settings
|
||||
$dbname = self::create_temp_db();
|
||||
DB::set_alternative_database_name($dbname);
|
||||
|
Loading…
Reference in New Issue
Block a user