Adding additional test for populateDefaults() in DataObjectTest

This commit is contained in:
Sean Harvey 2012-11-07 11:28:36 +13:00
parent a7efc76c36
commit 88366bf3c8

View File

@ -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');