From 19a45ce5446f1ebc87f98d294a3acffdc8b54478 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 28 Apr 2010 12:36:26 +0000 Subject: - Patch #765860 by effulgentsia, dww, dereine, mikey_p, sun: make drupal_alter() support multiple alter hooks executed by module weight. --- modules/simpletest/tests/form.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'modules/simpletest/tests/form.test') 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 @@ -209,6 +209,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. */ -- cgit v1.2.3