mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8568 from sminnee/test-subclass-default
MINOR: Add test for defaults on subclasses
This commit is contained in:
commit
b835b77574
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user