mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX #3919: Fix DataObject::dbObject() for decorated fields
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@75150 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8fcdcfa2eb
commit
b165bde578
@ -217,13 +217,13 @@ class ViewableData extends Object implements IteratorAggregate {
|
||||
if($componentClass == "DataObject") $isDataObject = true;
|
||||
|
||||
if(isset($isDataObject) && $isDataObject) {
|
||||
$fields = eval("return {$componentClass}::\$db;");
|
||||
$fields = Object::uninherited_static($componentClass, 'db');
|
||||
if($fields) foreach($fields as $fieldName => $fieldSchema) {
|
||||
$cache[$fieldName] = ViewableData::castingObjectCreatorPair($fieldSchema);
|
||||
}
|
||||
}
|
||||
if(isset($isViewableData) && $isViewableData) {
|
||||
$fields = eval("return {$componentClass}::\$casting;");
|
||||
$fields = Object::uninherited_static($componentClass, 'casting');
|
||||
if($fields) foreach($fields as $fieldName => $fieldSchema) {
|
||||
$cache[$fieldName] = ViewableData::castingObjectCreatorPair($fieldSchema);
|
||||
}
|
||||
|
@ -65,6 +65,14 @@ class DataObjectDecoratorTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that DataObject::dbObject() works for fields applied by a decorator
|
||||
*/
|
||||
function testDbObjectOnDecoratedFields() {
|
||||
$member = $this->objFromFixture('DataObjectDecoratorTest_Member', 'member1');
|
||||
$this->assertNotNull($member->dbObject('Website'));
|
||||
$this->assertType('Text', $member->dbObject('Website'));
|
||||
}
|
||||
}
|
||||
|
||||
class DataObjectDecoratorTest_Member extends DataObject implements TestOnly {
|
||||
|
@ -33,6 +33,10 @@ Member:
|
||||
Groups: =>Group.admingroup
|
||||
websiteuser:
|
||||
Email: websiteuser@test.com
|
||||
DataObjectDecoratorTest_Member:
|
||||
member1:
|
||||
Name: Sam
|
||||
Website: http://www.example.org
|
||||
DataObjectDecoratorTest_MyObject:
|
||||
object1:
|
||||
Title: Object 1
|
@ -69,6 +69,17 @@ class ObjectStaticTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that calls to Object::add_static() will update the data returned by Object::uninherited_static()
|
||||
*/
|
||||
public function testAddStaticFollowedByUnheritedCall() {
|
||||
Object::add_static_var('ObjectStaticTest_First', 'first', array('test_1b'));
|
||||
Object::add_static_var('ObjectStaticTest_Second', 'first', array('test_2b'));
|
||||
|
||||
$this->assertContains('test_1b', Object::uninherited_static('ObjectStaticTest_First', 'first'));
|
||||
$this->assertContains('test_2b', Object::uninherited_static('ObjectStaticTest_Second', 'first'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**#@+
|
||||
|
Loading…
x
Reference in New Issue
Block a user