BUGFIX Added setup/teardown routines to SiteTreeTest and SiteTreePermissionsTest to avoid breaking with Translatable enabled on recent canTranslate()/canEdit() extensions

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88143 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-10-05 21:00:49 +00:00
parent a0fd987b29
commit 16a67fe479
2 changed files with 56 additions and 0 deletions

View File

@ -9,6 +9,18 @@
class SiteTreePermissionsTest extends FunctionalTest {
static $fixture_file = "sapphire/tests/SiteTreePermissionsTest.yml";
static function set_up_once() {
SiteTreeTest::set_up_once();
parent::set_up_once();
}
static function tear_down_once() {
SiteTreeTest::tear_down_once();
parent::tear_down_once();
}
function setUp() {
parent::setUp();

View File

@ -5,6 +5,50 @@
*/
class SiteTreeTest extends SapphireTest {
static $fixture_file = 'sapphire/tests/SiteTreeTest.yml';
/**
* @todo Necessary because of monolithic Translatable design
*/
static protected $origTranslatableSettings = array();
static function set_up_once() {
// needs to recreate the database schema with language properties
self::kill_temp_db();
// store old defaults
self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable');
self::$origTranslatableSettings['default_locale'] = Translatable::default_locale();
// overwrite locale
Translatable::set_default_locale("en_US");
// refresh the decorated statics - different fields in $db with Translatable enabled
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);
parent::set_up_once();
}
static function tear_down_once() {
if(self::$origTranslatableSettings['has_extension'])
Object::add_extension('SiteTree', 'Translatable');
Translatable::set_default_locale(self::$origTranslatableSettings['default_locale']);
Translatable::set_current_locale(self::$origTranslatableSettings['default_locale']);
self::kill_temp_db();
self::create_temp_db();
parent::tear_down_once();
}
/**
* Test generation of the URLSegment values.