public function NodeCreationTest::testAuthorAutocomplete in Drupal 9
Same name and namespace in other branches
- 8 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 249
Class
- NodeCreationTest
- Create a node and test saving it.
Namespace
Drupal\Tests\node\FunctionalCode
public function testAuthorAutocomplete() {
$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);
}