diff --git a/modules/search/search.test b/modules/search/search.test index 09c879b..099bd4b 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -1473,7 +1473,7 @@ class SearchConfigSettingsForm extends DrupalWebTestCase { $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); $this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.'); } - + /** * Verify that you can disable individual search modules. */ @@ -2077,3 +2077,67 @@ class SearchSetLocaleTest extends DrupalWebTestCase { ->execute(); } } + +/** + * Test ability to use multiple submit handlers on search config page. + */ +class SearchMultipleSubmitHandlers extends DrupalWebTestCase { + public $search_user; + + public static function getInfo() { + return array( + 'name' => 'Multiple submit handlers', + 'description' => 'Verify that multiple submit handlers work on the search settings form.', + 'group' => 'Search', + ); + } + + function setUp() { + parent::setUp('search', 'search_submit_handlers'); + $this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks')); + $this->drupalLogin($this->search_user); + } + + /** + * Verify module-supplied settings form. + */ + function testSearchModuleSettingsPage() { + // Test that the settings form displays the correct count of items left to index. + $this->drupalGet('admin/config/search/settings'); + + // Ensure that the settings fieldset for the test module is not present on + // the page + $this->assertNoText(t('Extra type settings')); + $this->assertNoText(t('Boost method')); + + // Ensure that the test module is listed as an option + $this->assertTrue($this->xpath('//input[@id="edit-search-active-modules-search-submit-handlers"]'), 'Checkbox for activating search for an extra module is visible'); + $this->assertTrue($this->xpath('//input[@id="edit-search-default-module-search-submit-handlers"]'), 'Radio button for setting extra module as default search module is visible'); + + // Enable search for the test module + $edit['search_active_modules[search_submit_handlers]'] = 'search_submit_handlers'; + $edit['search_default_module'] = 'search_submit_handlers'; + $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); + + // Ensure that the settings fieldset is visible after enabling search for + // the test module + $this->assertText(t('Extra type settings')); + $this->assertText(t('Boost method')); + + // Ensure that the default setting was picked up from the default config + $this->assertTrue($this->xpath('//select[@id="edit-extra-type-settings-boost"]//option[@value="bi" and @selected="selected"]'), 'Module specific settings are picked up from the default config'); + + // Change extra type setting and also modify a common search setting. + $edit = array( + 'extra_type_settings[boost]' => 'ii', + 'minimum_word_size' => 8, + ); + $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); + $this->refreshVariables(); + + // Ensure that the modifications took effect. + $this->assertText(t('The configuration options have been saved.')); + $this->assertTrue($this->xpath('//select[@id="edit-extra-type-settings-boost"]//option[@value="ii" and @selected="selected"]'), 'Module specific settings can be changed'); + $this->assertTrue($this->xpath('//input[@id="edit-minimum-word-size" and @value="8"]'), 'Common search settings can be modified if a module-specific form is active'); + } +} \ No newline at end of file diff --git a/modules/search/tests/search_submit_handlers.info b/modules/search/tests/search_submit_handlers.info new file mode 100644 index 0000000..f2d4650 --- /dev/null +++ b/modules/search/tests/search_submit_handlers.info @@ -0,0 +1,6 @@ +name = "Search submit handlers form" +description = "Support module to verify search admin settings can accommodate multiple submit handlers." +package = Testing +version = VERSION +core = 7.x +hidden = TRUE \ No newline at end of file diff --git a/modules/search/tests/search_submit_handlers.module b/modules/search/tests/search_submit_handlers.module new file mode 100644 index 0000000..c7ec705 --- /dev/null +++ b/modules/search/tests/search_submit_handlers.module @@ -0,0 +1,50 @@ + 'Extra type settings', + ); +} + +/** + * Implements hook_search_admin(). + */ + +function search_submit_handlers_search_admin() { + // Output form for defining rank factor weights. + $form['extra_type_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Extra type settings'), + '#tree' => TRUE, + ); + + $form['extra_type_settings']['boost'] = array( + '#type' => 'select', + '#title' => t('Boost method'), + '#options' => array( + 'bi' => t('Bistromathic'), + 'ii' => t('Infinite Improbability'), + ), + '#default_value' => variable_get('extra_type_value', 'bi'), + ); + + $form['#submit'][] = 'search_submit_handlers_admin_submit'; + + return $form; +} + +/** + * Form API callback: Save admin settings + */ +function search_submit_handlers_admin_submit($form, &$form_state) { + + variable_set('extra_type_value', $form_state['values']['extra_type_settings']['boost']); + +} \ No newline at end of file