diff options
Diffstat (limited to 'modules/field/tests')
-rw-r--r-- | modules/field/tests/field.test | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index df58ecbd9..f7d9dddb2 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -1482,6 +1482,51 @@ class FieldFormTestCase extends FieldTestCase { // Test with several multiple fields in a form } + /** + * Tests widget handling of multiple required radios. + */ + function testFieldFormMultivalueWithRequiredRadio() { + // Create a multivalue test field. + $this->field = $this->field_unlimited; + $this->field_name = $this->field['field_name']; + $this->instance['field_name'] = $this->field_name; + field_create_field($this->field); + field_create_instance($this->instance); + $langcode = LANGUAGE_NONE; + + // Add a required radio field. + field_create_field(array( + 'field_name' => 'required_radio_test', + 'type' => 'list_text', + 'settings' => array( + 'allowed_values' => array('yes' => 'yes', 'no' => 'no'), + ), + )); + field_create_instance(array( + 'field_name' => 'required_radio_test', + 'entity_type' => 'test_entity', + 'bundle' => 'test_bundle', + 'required' => TRUE, + 'widget' => array( + 'type' => 'options_buttons', + ), + )); + + // Display creation form. + $this->drupalGet('test-entity/add/test-bundle'); + + // Press the 'Add more' button. + $this->drupalPost(NULL, array(), t('Add another item')); + + // Verify that no error is thrown by the radio element. + $this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed.'); + + // Verify that the widget is added. + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget 1 is displayed'); + $this->assertFieldByName("{$this->field_name}[$langcode][1][value]", '', 'New widget is displayed'); + $this->assertNoField("{$this->field_name}[$langcode][2][value]", 'No extraneous widget is displayed'); + } + function testFieldFormJSAddMore() { $this->field = $this->field_unlimited; $this->field_name = $this->field['field_name']; |