summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/form.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r--modules/simpletest/tests/form.test34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 7ecfde9ac..40c7490da 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -210,6 +210,40 @@ class FormsTestCase extends DrupalWebTestCase {
}
/**
+ * Test form alter hooks.
+ */
+class FormAlterTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Form alter hooks',
+ 'description' => 'Tests hook_form_alter() and hook_form_FORM_ID_alter().',
+ 'group' => 'Form API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('form_test');
+ }
+
+ /**
+ * Tests execution order of hook_form_alter() and hook_form_FORM_ID_alter().
+ */
+ function testExecutionOrder() {
+ $this->drupalGet('form-test/alter');
+ // Ensure that the order is first by module, then for a given module, the
+ // id-specific one after the generic one.
+ $expected = array(
+ 'block_form_form_test_alter_form_alter() executed.',
+ 'form_test_form_alter() executed.',
+ 'form_test_form_form_test_alter_form_alter() executed.',
+ 'system_form_form_test_alter_form_alter() executed.',
+ );
+ $content = preg_replace('/\s+/', ' ', filter_xss($this->content, array()));
+ $this->assert(strpos($content, implode(' ', $expected)) !== FALSE, t('Form alter hooks executed in the expected order.'));
+ }
+}
+
+/**
* Test form validation handlers.
*/
class FormValidationTestCase extends DrupalWebTestCase {