mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Added unit test to ensure LookupField can't save into a DataObject
This commit is contained in:
parent
0bf55cff39
commit
c07dcaa3af
@ -179,6 +179,34 @@ class FormTest extends FunctionalTest {
|
||||
);
|
||||
}
|
||||
|
||||
public function testLookupFieldDisabledSaving() {
|
||||
$object = new DataObjectTest_Team();
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
'Form',
|
||||
new FieldList(
|
||||
new LookupField('Players', 'Players')
|
||||
),
|
||||
new FieldList()
|
||||
);
|
||||
$form->loadDataFrom(array(
|
||||
'Players' => array(
|
||||
14,
|
||||
18,
|
||||
22
|
||||
),
|
||||
));
|
||||
$form->saveInto($object);
|
||||
$playersIds = $object->Players()->getIDList();
|
||||
|
||||
$this->assertTrue($form->validate());
|
||||
$this->assertEquals(
|
||||
$playersIds,
|
||||
array(),
|
||||
'saveInto() should not save into the DataObject for the LookupField'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoadDataFromIgnoreFalseish() {
|
||||
$form = new Form(
|
||||
new Controller(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user