mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.7' into 4.8
This commit is contained in:
commit
a6ccc86f94
@ -906,6 +906,7 @@ class TreeDropdownField extends FormField
|
||||
$data['data'] = array_merge($data['data'], [
|
||||
'urlTree' => $this->Link('tree'),
|
||||
'showSearch' => $this->getShowSearch(),
|
||||
'treeBaseId' => $this->getTreeBaseID(),
|
||||
'emptyString' => $this->getEmptyString(),
|
||||
'hasEmptyDefault' => $this->getHasEmptyDefault(),
|
||||
'multiple' => false,
|
||||
|
@ -266,4 +266,33 @@ class TreeDropdownFieldTest extends SapphireTest
|
||||
$field->getSchemaStateDefaults();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testTreeBaseID()
|
||||
{
|
||||
$treeBaseID = $this->idFromFixture(Folder::class, 'folder1');
|
||||
$field = new TreeDropdownField('TestTree', 'Test tree', Folder::class);
|
||||
|
||||
// getSchemaDataDefaults needs the field to be attach to a form
|
||||
new Form(
|
||||
null,
|
||||
'mock',
|
||||
new FieldList($field)
|
||||
);
|
||||
|
||||
$this->assertEmpty($field->getTreeBaseID(), 'TreeBaseId does not have an initial value');
|
||||
|
||||
$field->setTreeBaseID($treeBaseID);
|
||||
$this->assertEquals(
|
||||
$treeBaseID,
|
||||
$field->getTreeBaseID(),
|
||||
'Value passed to setTreeBaseID is returned by getTreeBaseID'
|
||||
);
|
||||
|
||||
$schema = $field->getSchemaDataDefaults();
|
||||
$this->assertEquals(
|
||||
$treeBaseID,
|
||||
$schema['data']['treeBaseId'],
|
||||
'TreeBaseId is included in the default schema data'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user