diff --git a/tests/model/DataObjectTest.php b/tests/model/DataObjectTest.php index 829c4986f..fe0889584 100644 --- a/tests/model/DataObjectTest.php +++ b/tests/model/DataObjectTest.php @@ -767,8 +767,14 @@ class DataObjectTest extends SapphireTest { $obj = new DataObjectTest_Fixture(); $this->assertEquals( $obj->MyFieldWithDefault, - "Default Value", - "Defaults are populated for in-memory object from \$defaults array" + 'Default Value', + 'Defaults are populated for in-memory object from $defaults array' + ); + + $this->assertEquals( + $obj->MyFieldWithAltDefault, + 'Default Value', + 'Defaults are populated from overloaded populateDefaults() method' ); } @@ -1126,7 +1132,6 @@ class DataObjectTest extends SapphireTest { DataObject::get(); } - } @@ -1191,18 +1196,25 @@ class DataObjectTest_Fixture extends DataObject implements TestOnly { 'Data' => 'Varchar', 'Duplicate' => 'Varchar', 'DbObject' => 'Varchar', - - // Field with default - 'MyField' => 'Varchar', - + // Field types - "DateField" => "Date", - "DatetimeField" => "Datetime", + 'DateField' => 'Date', + 'DatetimeField' => 'Datetime', + + 'MyFieldWithDefault' => 'Varchar', + 'MyFieldWithAltDefault' => 'Varchar' ); static $defaults = array( - 'MyFieldWithDefault' => 'Default Value', + 'MyFieldWithDefault' => 'Default Value', ); + + public function populateDefaults() { + parent::populateDefaults(); + + $this->MyFieldWithAltDefault = 'Default Value'; + } + } class DataObjectTest_SubTeam extends DataObjectTest_Team implements TestOnly { @@ -1294,6 +1306,7 @@ class DataObjectTest_TeamComment extends DataObject { static $has_one = array( 'Team' => 'DataObjectTest_Team' ); + } DataObject::add_extension('DataObjectTest_Team', 'DataObjectTest_Team_Extension');