protected function IntegrationTestBase::getAutocompleteSuggestions in Search API Autocomplete 8
Retrieves autocomplete suggestions from a field on the current page.
Parameters
string $field_html_id: (optional) The HTML ID of the field.
string $input: (optional) The input to write into the field. The default contains uppercase characters and accents to verify input is properly preprocessed.
Return value
\Behat\Mink\Element\NodeElement[] The suggestion elements from the page.
4 calls to IntegrationTestBase::getAutocompleteSuggestions()
- IntegrationTest::checkCustomAutocompleteScript in tests/
src/ FunctionalJavascript/ IntegrationTest.php - Tests whether using a custom autocomplete script is properly supported.
- IntegrationTest::checkLiveResultsAutocomplete in tests/
src/ FunctionalJavascript/ IntegrationTest.php - Tests autocomplete with the "Live results" suggester.
- IntegrationTest::checkSearchAutocomplete in tests/
src/ FunctionalJavascript/ IntegrationTest.php - Tests autocompletion in the search form.
- PagesIntegrationTest::checkAutocompleteFunctionality in tests/
src/ FunctionalJavascript/ PagesIntegrationTest.php - Checks that autocomplete works correctly.
File
- tests/
src/ FunctionalJavascript/ IntegrationTestBase.php, line 42
Class
- IntegrationTestBase
- Provides a base class for integration tests of this module.
Namespace
Drupal\Tests\search_api_autocomplete\FunctionalJavascriptCode
protected function getAutocompleteSuggestions($field_html_id = 'edit-keys', $input = 'Tést') {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$field = $assert_session
->elementExists('css', "input[data-drupal-selector=\"{$field_html_id}\"]");
$field
->setValue($input);
$this
->getSession()
->getDriver()
->keyDown($field
->getXpath(), substr($input, -1));
$element = $assert_session
->waitOnAutocomplete();
$this
->assertTrue($element && $element
->isVisible());
$this
->logPageChange();
// Contrary to documentation, this can also return NULL. Therefore, we need
// to make sure to return an array even in this case.
return $page
->findAll('css', '.ui-autocomplete .ui-menu-item') ?: [];
}