You are here

public function HelpPageTest::testHelpPageTree in Token 8

Tests the token browser on the token help page.

File

tests/src/Functional/Tree/HelpPageTest.php, line 38

Class

HelpPageTest
Tests token tree on help page.

Namespace

Drupal\Tests\token\Functional\Tree

Code

public function testHelpPageTree() {
  $this
    ->drupalGet('admin/help/token');
  $this
    ->assertText('The list of the currently available tokens on this site are shown below.');
  $this
    ->assertTokenGroup('Current date');
  $this
    ->assertTokenGroup('Site information');
  $this
    ->assertTokenInTree('[current-date:html_date]', 'current-date');
  $this
    ->assertTokenInTree('[current-date:html_week]', 'current-date');
  $this
    ->assertTokenInTree('[date:html_date]', 'date');
  $this
    ->assertTokenInTree('[date:html_week]', 'date');
  $this
    ->assertTokenInTree('[current-user:account-name]', 'current-user');
  $this
    ->assertTokenInTree('[user:account-name]', 'user');
  $this
    ->assertTokenInTree('[current-page:url:unaliased]', 'current-page--url');
  $this
    ->assertTokenInTree('[current-page:url:unaliased:args]', 'current-page--url--unaliased');
  $this
    ->assertTokenInTree('[user:original:account-name]', 'user--original');

  // Assert some of the restricted tokens to ensure they are shown.
  $this
    ->assertTokenInTree('[user:one-time-login-url]', 'user');
  $this
    ->assertTokenInTree('[user:original:cancel-url]', 'user--original');

  // The Array token is marked as nested, so it should not show up as a top
  // level token, only nested under another token. For instance, user:roles
  // is of type Array and tokens of type Array have 'nested' setting true.
  $this
    ->assertTokenNotGroup('Array');
  $this
    ->assertTokenNotGroup('user:roles');
  $this
    ->assertTokenInTree('[user:roles]', 'user');
}