1 form.test protected FormAutocompleteTestCase::getAutocompleteToken($id)

Returns the autocomplete token for an element on the current page.

Parameters

string $id: The HTML ID of the element that has an #autocomplete_path.

Return value

string|FALSE: The token, or FALSE if not found.

File

core/modules/simpletest/tests/form.test, line 2706
Unit tests for the Backdrop Form API.

Class

FormAutocompleteTestCase
Tests autocomplete form elements.

Code

protected function getAutocompleteToken($id) {
  $elements = $this->xpath('//input[@id=:id and contains(@class, "autocomplete")]', array(
    ':id' => $id . '-autocomplete',
  ));
  if (empty($elements[0]['data-autocomplete-token'])) {
    return FALSE;
  }
  return (string) $elements[0]['data-autocomplete-token'];
}