mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MNT Add test to cover TreeDropdownField::TreeBaseId
This commit is contained in:
parent
eedad00ebe
commit
440c7cad35
@ -8,6 +8,8 @@ use SilverStripe\Control\Session;
|
|||||||
use SilverStripe\Dev\CSSContentParser;
|
use SilverStripe\Dev\CSSContentParser;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
|
use SilverStripe\Forms\Form;
|
||||||
use SilverStripe\Forms\TreeDropdownField;
|
use SilverStripe\Forms\TreeDropdownField;
|
||||||
use SilverStripe\ORM\Tests\HierarchyTest\TestObject;
|
use SilverStripe\ORM\Tests\HierarchyTest\TestObject;
|
||||||
|
|
||||||
@ -246,4 +248,33 @@ class TreeDropdownFieldTest extends SapphireTest
|
|||||||
$result
|
$result
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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