function SearchConfigSettingsFormTest::testSearchSettingsPage
Same name in other branches
- 9 core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::testSearchSettingsPage()
- 8.9.x core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::testSearchSettingsPage()
- 11.x core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::testSearchSettingsPage()
Verifies the search settings form.
File
-
core/
modules/ search/ tests/ src/ Functional/ SearchConfigSettingsFormTest.php, line 93
Class
- SearchConfigSettingsFormTest
- Verify the search config settings form.
Namespace
Drupal\Tests\search\FunctionalCode
public function testSearchSettingsPage() : void {
// Test that the settings form displays the correct count of items left to index.
$this->drupalGet('admin/config/search/pages');
$this->assertSession()
->pageTextContains('There are 0 items left to index.');
// Test the re-index button.
$this->drupalGet('admin/config/search/pages');
$this->submitForm([], 'Re-index site');
$this->assertSession()
->pageTextContains('Are you sure you want to re-index the site');
$this->drupalGet('admin/config/search/pages/reindex');
$this->submitForm([], 'Re-index site');
$this->assertSession()
->statusMessageContains('All search indexes will be rebuilt', 'status');
$this->drupalGet('admin/config/search/pages');
$this->assertSession()
->pageTextContains('There is 1 item left to index.');
// Test that the form saves with the default values.
$this->drupalGet('admin/config/search/pages');
$this->submitForm([], 'Save configuration');
$this->assertSession()
->statusMessageContains('The configuration options have been saved.', 'status');
// Test that the form does not save with an invalid word length.
$edit = [
'minimum_word_size' => $this->randomMachineName(3),
];
$this->drupalGet('admin/config/search/pages');
$this->submitForm($edit, 'Save configuration');
$this->assertSession()
->statusMessageNotContains('The configuration options have been saved.');
$this->assertSession()
->statusMessageContains('Minimum word length to index must be a number.', 'error');
// Test logging setting. It should be off by default.
$text = $this->randomMachineName(5);
$this->drupalGet('search/node');
$this->submitForm([
'keys' => $text,
], 'Search');
$this->drupalGet('admin/reports/dblog');
$this->assertSession()
->linkNotExists('Searched Content for ' . $text . '.', 'Search was not logged');
// Turn on logging.
$edit = [
'logging' => TRUE,
];
$this->drupalGet('admin/config/search/pages');
$this->submitForm($edit, 'Save configuration');
$text = $this->randomMachineName(5);
$this->drupalGet('search/node');
$this->submitForm([
'keys' => $text,
], 'Search');
$this->drupalGet('admin/reports/dblog');
$this->assertSession()
->linkExists('Searched Content for ' . $text . '.', 0, 'Search was logged');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.