mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Let any DataObjectDecorator define an on_db_reset() method that is called by tests, like in Versioned. (from r97734)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99051 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d1bdb6e9d4
commit
d335bf671b
@ -569,9 +569,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
$dbConn = DB::getConn();
|
||||
$dbName = $dbConn->currentDatabase();
|
||||
if($dbName && DB::getConn()->databaseExists($dbName)) {
|
||||
// Todo: it would be good to remove this inappropriate coupling, somehow.
|
||||
// The versioned class keeps a static cache of information about temporary tables.
|
||||
Versioned::on_db_reset();
|
||||
// Some DataObjectsDecorators keep a static cache of information that needs to
|
||||
// be reset whenever the database is killed
|
||||
foreach(ClassInfo::subclassesFor('DataObjectDecorator') as $class) {
|
||||
$toCall = array($class, 'on_db_reset');
|
||||
if(is_callable($toCall)) call_user_func($toCall);
|
||||
}
|
||||
|
||||
// echo "Deleted temp database " . $dbConn->currentDatabase() . "\n";
|
||||
$dbConn->dropDatabase();
|
||||
@ -586,10 +589,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
if(self::using_temp_db()) {
|
||||
$dbadmin = new DatabaseAdmin();
|
||||
$dbadmin->clearAllData();
|
||||
|
||||
// Todo: it would be good to remove this inappropriate coupling, somehow.
|
||||
// The versioned class keeps a static cache of information about temporary tables.
|
||||
Versioned::on_db_reset();
|
||||
|
||||
// Some DataObjectsDecorators keep a static cache of information that needs to
|
||||
// be reset whenever the database is cleaned out
|
||||
foreach(ClassInfo::subclassesFor('DataObjectDecorator') as $class) {
|
||||
$toCall = array($class, 'on_db_reset');
|
||||
if(is_callable($toCall)) call_user_func($toCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user