mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
6bd2281b83
commit
78ceca6934
@ -1456,6 +1456,13 @@ class DataObjectTest extends SapphireTest
|
|||||||
'Default Value',
|
'Default Value',
|
||||||
'Defaults are populated from overloaded populateDefaults() method'
|
'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(
|
private static $db = array(
|
||||||
'Salary' => 'BigInt',
|
'Salary' => 'BigInt',
|
||||||
|
'EmploymentType' => 'Varchar',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $table_name = 'DataObjectTest_Staff';
|
private static $table_name = 'DataObjectTest_Staff';
|
||||||
@ -17,4 +18,8 @@ class Staff extends DataObject implements TestOnly
|
|||||||
'CurrentCompany' => Company::class,
|
'CurrentCompany' => Company::class,
|
||||||
'PreviousCompany' => Company::class
|
'PreviousCompany' => Company::class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $defaults = [
|
||||||
|
'EmploymentType' => 'Staff',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user