mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '3.6' into 3.7
This commit is contained in:
commit
4182d1b60c
@ -866,7 +866,7 @@ class Injector {
|
||||
return $this->instantiate($spec, $name);
|
||||
}
|
||||
|
||||
return $this->instantiate($spec);
|
||||
return $this->instantiate($spec, null, 'prototype');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,13 @@ class DataObjectTest extends SapphireTest {
|
||||
*/
|
||||
public function testSingleton($inst, $defaultValue, $altDefaultValue)
|
||||
{
|
||||
// Calls to scaffold the test database may have cached service specs for DataObjects
|
||||
// with the incorrect 'type' set (singleton instead of prototype)
|
||||
Injector::nest();
|
||||
$reflectionProp = new ReflectionProperty('Injector', 'specs');
|
||||
$reflectionProp->setAccessible(true);
|
||||
$reflectionProp->setValue(Injector::inst(), array());
|
||||
|
||||
$inst = $inst();
|
||||
// Test that populateDefaults() isn't called on singletons
|
||||
// which can lead to SQL errors during build, and endless loops
|
||||
@ -53,6 +60,8 @@ class DataObjectTest extends SapphireTest {
|
||||
} else {
|
||||
$this->assertEmpty($inst->MyFieldWithAltDefault);
|
||||
}
|
||||
|
||||
Injector::unnest();
|
||||
}
|
||||
|
||||
public function provideSingletons()
|
||||
|
Loading…
Reference in New Issue
Block a user