mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2017 from tractorcow/3.1-classname-test-fix
BUG Fixed major issue with testing dataobjects that implement TestOnly
This commit is contained in:
commit
a5b1a566d2
@ -92,6 +92,10 @@ class TestRunner extends Controller {
|
|||||||
Config::inst()->pushConfigStaticManifest(new SS_ConfigStaticManifest(
|
Config::inst()->pushConfigStaticManifest(new SS_ConfigStaticManifest(
|
||||||
BASE_PATH, true, isset($_GET['flush'])
|
BASE_PATH, true, isset($_GET['flush'])
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class
|
||||||
|
// (e.g. Member will now have various subclasses of DataObjects that implement TestOnly)
|
||||||
|
DataObject::clear_classname_spec_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
|
@ -193,6 +193,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
private static $classname_spec_cache = array();
|
private static $classname_spec_cache = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all cached classname specs. It's necessary to clear all cached subclassed names
|
||||||
|
* for any classes if a new class manifest is generated.
|
||||||
|
*/
|
||||||
|
public static function clear_classname_spec_cache() {
|
||||||
|
self::$classname_spec_cache = array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the complete map of fields on this object, including "Created", "LastEdited" and "ClassName".
|
* Return the complete map of fields on this object, including "Created", "LastEdited" and "ClassName".
|
||||||
* See {@link custom_database_fields()} for a getter that excludes these "base fields".
|
* See {@link custom_database_fields()} for a getter that excludes these "base fields".
|
||||||
@ -202,7 +210,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
public static function database_fields($class) {
|
public static function database_fields($class) {
|
||||||
if(get_parent_class($class) == 'DataObject') {
|
if(get_parent_class($class) == 'DataObject') {
|
||||||
if(!isset(self::$classname_spec_cache[$class])) {
|
if(empty(self::$classname_spec_cache[$class])) {
|
||||||
$classNames = ClassInfo::subclassesFor($class);
|
$classNames = ClassInfo::subclassesFor($class);
|
||||||
|
|
||||||
$db = DB::getConn();
|
$db = DB::getConn();
|
||||||
|
Loading…
Reference in New Issue
Block a user