You are here

public function NodeCreationTest::testAuthorAutocomplete in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/node/src/Tests/NodeCreationTest.php \Drupal\node\Tests\NodeCreationTest::testAuthorAutocomplete()

Tests the author autocompletion textfield.

File

core/modules/node/src/Tests/NodeCreationTest.php, line 150
Contains \Drupal\node\Tests\NodeCreationTest.

Class

NodeCreationTest
Create a node and test saving it.

Namespace

Drupal\node\Tests

Code

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