diff --git a/core/modules/search/lib/Drupal/search/SearchPageListController.php b/core/modules/search/lib/Drupal/search/SearchPageListController.php index e835c01..6d1fb08 100644 --- a/core/modules/search/lib/Drupal/search/SearchPageListController.php +++ b/core/modules/search/lib/Drupal/search/SearchPageListController.php @@ -281,11 +281,11 @@ public function submitForm(array &$form, array &$form_state) { if (($search_settings->get('index.minimum_word_size') != $form_state['values']['minimum_word_size']) || ($search_settings->get('index.overlap_cjk') != $form_state['values']['overlap_cjk'])) { $search_settings->set('index.minimum_word_size', $form_state['values']['minimum_word_size']); $search_settings->set('index.overlap_cjk', $form_state['values']['overlap_cjk']); + $search_settings->save(); drupal_set_message($this->t('The index will be rebuilt.')); search_reindex(); } - drupal_set_message($this->t('The configuration options have been saved.')); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php index 8fe78fb..67333a9 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php @@ -85,12 +85,29 @@ function testSearchSettingsPage() { $this->drupalPostForm('admin/config/search/settings', array(), t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), 'Form saves with the default values.'); + // Ensure that the default settings were picked up from the default config + $search_settings = \Drupal::config('search.settings'); + $this->assertEqual($search_settings->get('index.minimum_word_size'), 3, 'Minimum word length was picked up from the default config'); + $this->assertTrue($search_settings->get('index.overlap_cjk'), 'Simple CJK handling was picked up from the default config'); + + // Test that the form saves changes to minimum word length and simple CJK handling. + $edit = array( + 'minimum_word_size' => 5, + 'overlap_cjk' => FALSE, + ); + $this->drupalPostForm('admin/config/search/settings', $edit, t('Save configuration')); + $this->assertText(t('The index will be rebuilt.'), 'Index is rebuilt when minimum word length and simple CJK handling options are changed.'); + $search_settings = \Drupal::config('search.settings'); + $this->assertEqual($search_settings->get('index.minimum_word_size'), 5, 'Change to minimum word length option was saved.'); + $this->assertFalse($search_settings->get('index.overlap_cjk'), 'Change to simple CJK handling option was saved.'); + // Test that the form does not save with an invalid word length. $edit = array( 'minimum_word_size' => $this->randomName(3), ); $this->drupalPostForm('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.'); + $this->assertNoText(t('The index will be rebuilt.'), 'Index is not rebuilt when failing to change minimum word length.'); } /**