Merge pull request #8568 from sminnee/test-subclass-default

MINOR: Add test for defaults on subclasses
This commit is contained in:
Loz Calver 2018-11-05 10:34:12 +01:00 committed by GitHub
commit b835b77574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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',
];
}