mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Adding additional test for populateDefaults() in DataObjectTest
This commit is contained in:
parent
a7efc76c36
commit
88366bf3c8
@ -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'
|
||||
);
|
||||
}
|
||||
|
||||
@ -1127,7 +1133,6 @@ class DataObjectTest extends SapphireTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class DataObjectTest_Player extends Member implements TestOnly {
|
||||
@ -1192,17 +1197,24 @@ class DataObjectTest_Fixture extends DataObject implements TestOnly {
|
||||
'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',
|
||||
);
|
||||
|
||||
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');
|
||||
|
Loading…
Reference in New Issue
Block a user