MINOR: Add test for defaults on subclasses

This was raised in https://github.com/silverstripe/silverstripe-framework/issues/8567
and wasn’t covered by a test.
This commit is contained in:
Sam Minnee 2018-11-05 16:09:49 +13:00
parent 6bd2281b83
commit 78ceca6934
2 changed files with 12 additions and 0 deletions

View File

@ -1456,6 +1456,13 @@ class DataObjectTest extends SapphireTest
'Default Value',
'Defaults are populated from overloaded populateDefaults() method'
);
// Test populate defaults on subclasses
$staffObj = new DataObjectTest\Staff();
$this->assertEquals('Staff', $staffObj->EmploymentType);
$ceoObj = new DataObjectTest\CEO();
$this->assertEquals('Staff', $ceoObj->EmploymentType);
}
/**

View File

@ -9,6 +9,7 @@ class Staff extends DataObject implements TestOnly
{
private static $db = array(
'Salary' => 'BigInt',
'EmploymentType' => 'Varchar',
);
private static $table_name = 'DataObjectTest_Staff';
@ -17,4 +18,8 @@ class Staff extends DataObject implements TestOnly
'CurrentCompany' => Company::class,
'PreviousCompany' => Company::class
);
private static $defaults = [
'EmploymentType' => 'Staff',
];
}