function ElementTest::testFormAutocomplete
Same name in other branches
- 8.9.x core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testFormAutocomplete()
- 10 core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testFormAutocomplete()
- 11.x core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testFormAutocomplete()
Tests a form with an autocomplete setting..
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ ElementTest.php, line 168
Class
- ElementTest
- Tests building and processing of core form elements.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testFormAutocomplete() {
$this->drupalGet('form-test/autocomplete');
// Ensure that the user does not have access to the autocompletion.
$this->assertSession()
->elementNotExists('xpath', '//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');
$this->assertSession()
->elementNotExists('xpath', '//input[@id="edit-autocomplete-2" and contains(@data-autocomplete-path, "form-test/autocomplete-2/value")]');
$user = $this->drupalCreateUser([
'access autocomplete test',
]);
$this->drupalLogin($user);
$this->drupalGet('form-test/autocomplete');
// Make sure that the autocomplete library is added.
$this->assertSession()
->responseContains('core/misc/autocomplete.js');
// Ensure that the user does have access to the autocompletion.
$this->assertSession()
->elementExists('xpath', '//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');
$this->assertSession()
->elementExists('xpath', '//input[@id="edit-autocomplete-2" and contains(@data-autocomplete-path, "form-test/autocomplete-2/value")]');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.