Esempio n. 1
0
 function testPopulateFromPostData()
 {
     $this->logInWithPermission('ADMIN');
     $set = new ArrayList();
     $field = new EditableFormField();
     $data = array('Title' => 'Field Title', 'Default' => 'Default Value', 'Sort' => '2', 'Required' => 0, 'CustomErrorMessage' => 'Custom');
     $field->populateFromPostData($data);
     $set->push($field);
     $this->assertDOSEquals(array($data), $set);
     // test the custom settings
     $data['CustomSettings'] = array('Foo' => 'Bar');
     $checkbox = new EditableCheckbox();
     $checkbox->write();
     $checkbox->populateFromPostData(array('Title' => 'Checkbox'));
     $field->populateFromPostData($data);
     $this->assertEquals($field->getSettings(), array('Foo' => 'Bar'));
     $rule = array('Display' => 'Hide', 'ConditionField' => $checkbox->Name, 'ConditionOption' => 'HasValue', 'Value' => 6);
     // test the custom rules
     $data['CustomRules'] = array('Rule1' => $rule);
     $field->populateFromPostData($data);
     $rules = unserialize($field->CustomRules);
     $this->assertEquals($rules[0], $rule);
 }