public function AutocompleteTest::testNodeAutocomplete in Token 8
Tests autocomplete for node tokens.
File
- tests/
src/ Functional/ Tree/ AutocompleteTest.php, line 25
Class
- AutocompleteTest
- Test token autocomplete.
Namespace
Drupal\Tests\token\Functional\TreeCode
public function testNodeAutocomplete() {
$url_prefix = "token/autocomplete/node/";
$url = $url_prefix . 'Title of [nod';
$response = Json::decode($this
->drupalGet($url, [
'query' => [
'_format' => 'json',
],
]));
$this
->assertArrayHasKey('[node:nid]', $response);
$this
->assertArrayHasKey('[node:author]', $response);
$this
->assertArrayHasKey('[node:url]', $response);
$this
->assertArrayHasKey('[node:url:', $response);
$url = $url_prefix . 'Title of [node:url:';
$response = Json::decode($this
->drupalGet($url, [
'query' => [
'_format' => 'json',
],
]));
$this
->assertArrayHasKey('[node:url:path]', $response);
$this
->assertArrayHasKey('[node:url:absolute]', $response);
}