function NodeCreationTest::testAuthorAutocomplete

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::testAuthorAutocomplete()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::testAuthorAutocomplete()
  3. 11.x core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::testAuthorAutocomplete()

Tests the author autocompletion textfield.

File

core/modules/node/tests/src/Functional/NodeCreationTest.php, line 262

Class

NodeCreationTest
Create a node and test saving it.

Namespace

Drupal\Tests\node\Functional

Code

public function testAuthorAutocomplete() : void {
  $admin_user = $this->drupalCreateUser([
    'administer nodes',
    'create page content',
  ]);
  $this->drupalLogin($admin_user);
  $this->drupalGet('node/add/page');
  // Verify that no autocompletion exists without access user profiles.
  $this->assertSession()
    ->elementNotExists('xpath', '//input[@id="edit-uid-0-value" and contains(@data-autocomplete-path, "user/autocomplete")]');
  $admin_user = $this->drupalCreateUser([
    'administer nodes',
    'create page content',
    'access user profiles',
  ]);
  $this->drupalLogin($admin_user);
  $this->drupalGet('node/add/page');
  // Ensure that the user does have access to the autocompletion.
  $this->assertSession()
    ->elementsCount('xpath', '//input[@id="edit-uid-0-target-id" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/user/default")]', 1);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.