mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.6' into 4.7
This commit is contained in:
commit
e6aeff6468
@ -904,6 +904,7 @@ class TreeDropdownField extends FormField
|
|||||||
$data['data'] = array_merge($data['data'], [
|
$data['data'] = array_merge($data['data'], [
|
||||||
'urlTree' => $this->Link('tree'),
|
'urlTree' => $this->Link('tree'),
|
||||||
'showSearch' => $this->getShowSearch(),
|
'showSearch' => $this->getShowSearch(),
|
||||||
|
'treeBaseId' => $this->getTreeBaseID(),
|
||||||
'emptyString' => $this->getEmptyString(),
|
'emptyString' => $this->getEmptyString(),
|
||||||
'hasEmptyDefault' => $this->getHasEmptyDefault(),
|
'hasEmptyDefault' => $this->getHasEmptyDefault(),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
|
@ -266,4 +266,33 @@ class TreeDropdownFieldTest extends SapphireTest
|
|||||||
$field->getSchemaStateDefaults();
|
$field->getSchemaStateDefaults();
|
||||||
$this->assertTrue(true);
|
$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