mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Added static resetting methods for more reliable test execution.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84147 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6f0a1e9d36
commit
5f6bee22ba
@ -2648,6 +2648,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
self::$cache_get_one = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset internal caches, for example after test runs
|
||||
*/
|
||||
static function reset() {
|
||||
self::$cache_get_one = array();
|
||||
self::$cache_buildSQL_query = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the hard work for get_one()
|
||||
|
@ -194,6 +194,16 @@ class Translatable extends DataObjectDecorator {
|
||||
*/
|
||||
protected static $allowed_locales = null;
|
||||
|
||||
/**
|
||||
* Reset static configuration variables to their default values
|
||||
*/
|
||||
static function reset() {
|
||||
self::$default_locale = 'en_US';
|
||||
self::$current_locale = null;
|
||||
self::$enable_lang_filter = true;
|
||||
self::$allowed_locales = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose the language the site is currently on.
|
||||
*
|
||||
|
@ -68,6 +68,17 @@ class Versioned extends DataObjectDecorator {
|
||||
'AuthorID' => true,
|
||||
'PublisherID' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
* Reset static configuration variables to their default values
|
||||
*/
|
||||
static function reset() {
|
||||
self::$reading_stage = null;
|
||||
self::$reading_archived_date = null;
|
||||
|
||||
Session::clear('currentStage');
|
||||
Session::clear('archiveDate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Versioned object.
|
||||
|
@ -50,6 +50,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
$this->originalRequirements = Requirements::backend();
|
||||
Member::set_password_validator(null);
|
||||
Cookie::set_report_errors(false);
|
||||
|
||||
// Reset Translatable and Versioned
|
||||
Translatable::reset();
|
||||
Versioned::reset();
|
||||
DataObject::reset();
|
||||
Controller::curr()->setSession(new Session(array()));
|
||||
|
||||
$className = get_class($this);
|
||||
$fixtureFile = eval("return {$className}::\$fixture_file;");
|
||||
@ -62,9 +68,6 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
//echo "done.\n";
|
||||
}
|
||||
|
||||
// This code is a bit misplaced; we want some way of the whole session being reinitialised...
|
||||
Versioned::reading_stage(null);
|
||||
|
||||
singleton('DataObject')->flushCache();
|
||||
|
||||
$dbadmin = new DatabaseAdmin();
|
||||
|
Loading…
Reference in New Issue
Block a user