function NodeCreationTest::testAuthorAutocomplete
Tests the author autocompletion textfield.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeCreationTest.php, line 265
Class
- NodeCreationTest
- Create a node and test saving it.
Namespace
Drupal\Tests\node\FunctionalCode
public function testAuthorAutocomplete() : void {
$admin_user = $this->drupalCreateUser([
'create page content',
]);
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
$this->assertSession()
->statusCodeEquals(200);
// Verify that no autocompletion exists without administer nodes.
$selector = '//input[@id="edit-uid-0-target-id" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/user/default")]';
$this->assertSession()
->elementNotExists('xpath', $selector);
$admin_user = $this->drupalCreateUser([
'administer nodes',
'create page content',
]);
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
// Ensure that the user does have access to the autocompletion.
$this->assertSession()
->elementsCount('xpath', $selector, 1);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.