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:
Ingo Schommer 2008-10-09 14:32:47 +00:00
parent de1218e8db
commit b6ffe7b939

View File

@ -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()'
);
}
}