mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Added unit test CheckboxSetFieldTest?->testLoadDataFromObject()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63996 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
de1218e8db
commit
b6ffe7b939
@ -59,8 +59,28 @@ class CheckboxSetFieldTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testLoadDataFrom() {
|
||||
|
||||
function testLoadDataFromObject() {
|
||||
$article = $this->fixture->objFromFixture('CheckboxSetFieldTest_Article', 'articlewithouttags');
|
||||
$articleWithTags = $this->fixture->objFromFixture('CheckboxSetFieldTest_Article', 'articlewithtags');
|
||||
$tag1 = $this->fixture->objFromFixture('CheckboxSetFieldTest_Tag', 'tag1');
|
||||
$tag2 = $this->fixture->objFromFixture('CheckboxSetFieldTest_Tag', 'tag2');
|
||||
|
||||
$field = new CheckboxSetField("Tags", "Test field", DataObject::get("CheckboxSetFieldTest_Tag")->map());
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
'Form',
|
||||
new FieldSet($field),
|
||||
new FieldSet()
|
||||
);
|
||||
$form->loadDataFrom($articleWithTags);
|
||||
$this->assertEquals(
|
||||
array(
|
||||
$tag1->ID => $tag1->ID,
|
||||
$tag2->ID => $tag2->ID
|
||||
),
|
||||
$field->Value(),
|
||||
'CheckboxSetField properly loads data from a manymany relationship in an object through Form->loadDataFrom()'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user