diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-13 09:41:32 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-13 09:41:32 -0700 |
commit | 1569c4bde2de6097de2abd6f5f66d62f0cede3c5 (patch) | |
tree | cebbe6b6cd504d1e4116175072684f70e13526e9 /modules/field/tests | |
parent | c29e269956ca92d83c62ccef4fda6c571e802101 (diff) | |
download | brdo-1569c4bde2de6097de2abd6f5f66d62f0cede3c5.tar.gz brdo-1569c4bde2de6097de2abd6f5f66d62f0cede3c5.tar.bz2 |
Issue #811542 by bojanz, sun, mlncn, chx, pillarsdotnet, loganfsmyth, xjm: Fixed Regression: Required radios throw illegal choice error when none selected.
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']; |