function SearchConfigSettingsFormTest::testSearchModuleSettingsPage

Verify module-supplied settings form.

File

drupal/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php, line 91
Definition of Drupal\search\Tests\SearchConfigSettingsFormTest.

Class

SearchConfigSettingsFormTest
Test config page.

Namespace

Drupal\search\Tests

Code

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-active-modules-search-extra-type"]'), 'Checkbox for activating search for an extra module is visible');
  $this
    ->assertTrue($this
    ->xpath('//input[@id="edit-default-module-search-extra-type"]'), 'Radio button for setting extra module as default search module is visible');

  // Enable search for the test module
  $edit['active_modules[search_extra_type]'] = 'search_extra_type';
  $edit['default_module'] = 'search_extra_type';
  $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' => 5,
  );
  $this
    ->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));

  // 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="5"]'), 'Common search settings can be modified if a module-specific form is active');
}