BUGFIX Fixing regression in TranslatableTest due to outdated singleton caching.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89911 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-10-22 00:30:21 +00:00
parent 11d5ce0274
commit e1a47de20e
4 changed files with 23 additions and 18 deletions

View File

@ -65,11 +65,6 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
DataObject::reset(); DataObject::reset();
SiteTree::reset(); SiteTree::reset();
Controller::curr()->setSession(new Session(array())); 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); $className = get_class($this);
$fixtureFile = eval("return {$className}::\$fixture_file;"); $fixtureFile = eval("return {$className}::\$fixture_file;");
@ -119,6 +114,10 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
* for tearing down the state again. * for tearing down the state again.
*/ */
static function set_up_once() { static function set_up_once() {
// clear singletons, they're caching old extension info
// which is used in DatabaseAdmin->doBuild()
global $_SINGLETONS;
$_SINGLETONS = array();
} }
/** /**
@ -228,11 +227,6 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
} }
function tearDown() { function tearDown() {
// clear singletons, they're caching old extension info
// which is used in DatabaseAdmin->doBuild()
global $_SINGLETONS;
$_SINGLETONS = array();
// Restore email configuration // Restore email configuration
Email::set_mailer($this->originalMailer); Email::set_mailer($this->originalMailer);
$this->originalMailer = null; $this->originalMailer = null;
@ -250,6 +244,10 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
} }
static function tear_down_once() { static function tear_down_once() {
// clear singletons, they're caching old extension info
// which is used in DatabaseAdmin->doBuild()
global $_SINGLETONS;
$_SINGLETONS = array();
} }
/** /**

View File

@ -9,6 +9,13 @@
*/ */
class ObjectTest extends SapphireTest { class ObjectTest extends SapphireTest {
function setUp() {
parent::setUp();
global $_SINGLETONS;
$_SINGLETONS = array();
}
function testHasmethodBehaviour() { function testHasmethodBehaviour() {
/* SiteTree should have all of the methods that Versioned has, because Versioned is listed in SiteTree's /* SiteTree should have all of the methods that Versioned has, because Versioned is listed in SiteTree's
* extensions */ * extensions */

View File

@ -15,11 +15,13 @@ class TranslatableTest extends FunctionalTest {
static protected $origTranslatableSettings = array(); static protected $origTranslatableSettings = array();
static function set_up_once() { static function set_up_once() {
parent::set_up_once();
// needs to recreate the database schema with language properties // needs to recreate the database schema with language properties
self::kill_temp_db(); self::kill_temp_db();
// store old defaults // store old defaults
self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable'); self::$origTranslatableSettings['has_extension'] = Object::has_extension('SiteTree', 'Translatable');
self::$origTranslatableSettings['default_locale'] = Translatable::default_locale(); self::$origTranslatableSettings['default_locale'] = Translatable::default_locale();
// overwrite locale // overwrite locale
@ -28,12 +30,10 @@ class TranslatableTest extends FunctionalTest {
// refresh the decorated statics - different fields in $db with Translatable enabled // refresh the decorated statics - different fields in $db with Translatable enabled
if(!self::$origTranslatableSettings['has_extension']) Object::add_extension('SiteTree', 'Translatable'); if(!self::$origTranslatableSettings['has_extension']) Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('TranslatableTest_DataObject', 'Translatable'); Object::add_extension('TranslatableTest_DataObject', 'Translatable');
// recreate database with new settings // recreate database with new settings
$dbname = self::create_temp_db(); $dbname = self::create_temp_db();
DB::set_alternative_database_name($dbname); DB::set_alternative_database_name($dbname);
parent::set_up_once();
} }
static function tear_down_once() { static function tear_down_once() {
@ -832,7 +832,7 @@ class TranslatableTest extends FunctionalTest {
)); ));
$form->saveInto($frPage); $form->saveInto($frPage);
$frPage->write(); $frPage->write();
$this->assertEquals('Translated', $frPage->Title); $this->assertEquals('Translated', $frPage->Title);
$this->assertEquals(array($group->ID), $frPage->ViewerGroups()->column('ID')); $this->assertEquals(array($group->ID), $frPage->ViewerGroups()->column('ID'));

View File

@ -15,11 +15,13 @@ class TranslatableSearchFormTest extends FunctionalTest {
static protected $origTranslatableSettings = array(); static protected $origTranslatableSettings = array();
static function set_up_once() { static function set_up_once() {
parent::set_up_once();
// needs to recreate the database schema with language properties // needs to recreate the database schema with language properties
self::kill_temp_db(); self::kill_temp_db();
// store old defaults // store old defaults
self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable'); self::$origTranslatableSettings['has_extension'] = Object::has_extension('SiteTree', 'Translatable');
self::$origTranslatableSettings['default_locale'] = Translatable::default_locale(); self::$origTranslatableSettings['default_locale'] = Translatable::default_locale();
// overwrite locale // overwrite locale
@ -32,8 +34,6 @@ class TranslatableSearchFormTest extends FunctionalTest {
// recreate database with new settings // recreate database with new settings
$dbname = self::create_temp_db(); $dbname = self::create_temp_db();
DB::set_alternative_database_name($dbname); DB::set_alternative_database_name($dbname);
parent::set_up_once();
} }
function setUp() { function setUp() {