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