diff options
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r-- | modules/simpletest/tests/form.test | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index 1f76318f5..a0df09052 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -370,6 +370,66 @@ class FormsTestCase extends DrupalWebTestCase { } /** + * Tests building and processing of core form elements. + */ +class FormElementTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + + public static function getInfo() { + return array( + 'name' => 'Element processing', + 'description' => 'Tests building and processing of core form elements.', + 'group' => 'Form API', + ); + } + + function setUp() { + parent::setUp(array('form_test')); + } + + /** + * Tests expansion of #options for #type checkboxes and radios. + */ + function testOptions() { + $this->drupalGet('form-test/checkboxes-radios'); + + // Verify that all options appear in their defined order. + foreach (array('checkbox', 'radio') as $type) { + $elements = $this->xpath('//input[@type=:type]', array(':type' => $type)); + $expected_values = array('0', 'foo', '1', 'bar'); + foreach ($elements as $element) { + $expected = array_shift($expected_values); + $this->assertIdentical((string) $element['value'], $expected); + } + } + + // Enable customized option sub-elements. + $this->drupalGet('form-test/checkboxes-radios/customize'); + + // Verify that all options appear in their defined order, taking a custom + // #weight into account. + foreach (array('checkbox', 'radio') as $type) { + $elements = $this->xpath('//input[@type=:type]', array(':type' => $type)); + $expected_values = array('0', 'foo', 'bar', '1'); + foreach ($elements as $element) { + $expected = array_shift($expected_values); + $this->assertIdentical((string) $element['value'], $expected); + } + } + // Verify that custom #description properties are output. + foreach (array('checkboxes', 'radios') as $type) { + $elements = $this->xpath('//input[@name=:name]/following-sibling::div[@class=:class]', array( + ':name' => $type . '[foo]', + ':class' => 'description', + )); + $this->assertTrue(count($elements), t('Custom %type option description found.', array( + '%type' => $type, + ))); + } + } +} + +/** * Test form alter hooks. */ class FormAlterTestCase extends DrupalWebTestCase { |