function SearchConfigSettingsFormTest::testSearchSettingsPage
Same name in other branches
- 9 core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php \Drupal\Tests\search\Functional\SearchConfigSettingsFormTest::testSearchSettingsPage()
- 10 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 87
Class
- SearchConfigSettingsFormTest
- Verify the search config settings form.
Namespace
Drupal\Tests\search\FunctionalCode
public function testSearchSettingsPage() {
// Test that the settings form displays the correct count of items left to index.
$this->drupalGet('admin/config/search/pages');
$this->assertText(t('There are @count items left to index.', [
'@count' => 0,
]));
// Test the re-index button.
$this->drupalPostForm('admin/config/search/pages', [], t('Re-index site'));
$this->assertText(t('Are you sure you want to re-index the site'));
$this->drupalPostForm('admin/config/search/pages/reindex', [], t('Re-index site'));
$this->assertText(t('All search indexes will be rebuilt'));
$this->drupalGet('admin/config/search/pages');
$this->assertText(t('There is 1 item left to index.'));
// Test that the form saves with the default values.
$this->drupalPostForm('admin/config/search/pages', [], 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 = [
'minimum_word_size' => $this->randomMachineName(3),
];
$this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration'));
$this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.');
// Test logging setting. It should be off by default.
$text = $this->randomMachineName(5);
$this->drupalPostForm('search/node', [
'keys' => $text,
], t('Search'));
$this->drupalGet('admin/reports/dblog');
$this->assertSession()
->linkNotExists('Searched Content for ' . $text . '.', 'Search was not logged');
// Turn on logging.
$edit = [
'logging' => TRUE,
];
$this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration'));
$text = $this->randomMachineName(5);
$this->drupalPostForm('search/node', [
'keys' => $text,
], t('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.