You are here

public function AutocompleteTest::testUserAutocomplete in Token 8

Tests autocomplete for user tokens.

File

tests/src/Functional/Tree/AutocompleteTest.php, line 54

Class

AutocompleteTest
Test token autocomplete.

Namespace

Drupal\Tests\token\Functional\Tree

Code

public function testUserAutocomplete() {
  $url_prefix = "token/autocomplete/user/";
  $url = $url_prefix . 'Name of the [us';
  $response = Json::decode($this
    ->drupalGet($url, [
    'query' => [
      '_format' => 'json',
    ],
  ]));
  $this
    ->assertArrayHasKey('[user:uid]', $response);
  $this
    ->assertArrayHasKey('[user:original]', $response);
  $this
    ->assertArrayHasKey('[user:url]', $response);
  $this
    ->assertArrayHasKey('[user:url:', $response);
  $url = $url_prefix . 'Title of [user:original:';
  $response = Json::decode($this
    ->drupalGet($url, [
    'query' => [
      '_format' => 'json',
    ],
  ]));
  $this
    ->assertArrayHasKey('[user:original:uid]', $response);
}