mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
3c1d81d014
API change: refactored Form() into getFormFields(), getFormActions(), getRequiredFields() ENHANCEMENT: added updateForm* extension hooks to allow customization of userforms BUGFIX: gave custom scripts their own ID to enable it to be blocked.
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package userforms
|
|
*/
|
|
|
|
class EditableFormFieldTest extends FunctionalTest {
|
|
|
|
static $fixture_file = 'userforms/tests/EditableFormFields.yml';
|
|
|
|
function testEditableDropdownField() {
|
|
$dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown');
|
|
|
|
$option1 = $this->objFromFixture('EditableOption', 'option-1');
|
|
$option2 = $this->objFromFixture('EditableOption', 'option-2');
|
|
|
|
$dropdown->Options()->add($option1);
|
|
$dropdown->Options()->add($option2);
|
|
|
|
$field = $dropdown->getFormField();
|
|
|
|
|
|
$this->assertThat($field, $this->isInstanceOf('DropdownField'));
|
|
$values = $field->getSource();
|
|
|
|
$this->assertEquals(array('Option 1' => 'Option 1', 'Option 2' => 'Option 2'), $values);
|
|
}
|
|
|
|
function testEditableRadioField() {
|
|
$radio = $this->objFromFixture('EditableRadioField', 'radio-field');
|
|
|
|
$option1 = $this->objFromFixture('EditableOption', 'option-1');
|
|
$option2 = $this->objFromFixture('EditableOption', 'option-2');
|
|
|
|
$radio->Options()->add($option1);
|
|
$radio->Options()->add($option2);
|
|
|
|
$field = $radio->getFormField();
|
|
|
|
$this->assertThat($field, $this->isInstanceOf('OptionsetField'));
|
|
$values = $field->getSource();
|
|
|
|
$this->assertEquals(array('Option 1' => 'Option 1', 'Option 2' => 'Option 2'), $values);
|
|
}
|
|
} |