function SearchConfigSettingsFormTest::testSearchSettingsPage

Verify the search settings form.

File

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

Class

SearchConfigSettingsFormTest
Test config page.

Namespace

Drupal\search\Tests

Code

function testSearchSettingsPage() {

  // Test that the settings form displays the correct count of items left to index.
  $this
    ->drupalGet('admin/config/search/settings');
  $this
    ->assertText(t('There are @count items left to index.', array(
    '@count' => 0,
  )));

  // Test the re-index button.
  $this
    ->drupalPost('admin/config/search/settings', array(), t('Re-index site'));
  $this
    ->assertText(t('Are you sure you want to re-index the site'));
  $this
    ->drupalPost('admin/config/search/settings/reindex', array(), t('Re-index site'));
  $this
    ->assertText(t('The index will be rebuilt'));
  $this
    ->drupalGet('admin/config/search/settings');
  $this
    ->assertText(t('There is 1 item left to index.'));

  // Test that the form saves with the default values.
  $this
    ->drupalPost('admin/config/search/settings', array(), t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'), 'Form saves with the default values.');

  // Test that the form does not save with an invalid word length.
  $edit = array(
    'minimum_word_size' => $this
      ->randomName(3),
  );
  $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.');
}