You are here

protected function TokenTreeTestTrait::getXpathForTokenInTree in Token 8

Get xpath to check for token in tree.

Parameters

$token: The token name with the surrounding square brackets [].

string $parent: (optional) The parent CSS identifier of this token.

Return value

string The xpath to check for the token and parent.

2 calls to TokenTreeTestTrait::getXpathForTokenInTree()
TokenTreeTestTrait::assertTokenInTree in tests/src/Functional/Tree/TokenTreeTestTrait.php
Check to see if the specified token is present in the token browser.
TokenTreeTestTrait::assertTokenNotInTree in tests/src/Functional/Tree/TokenTreeTestTrait.php
Check to see if the specified token is present in the token browser.

File

tests/src/Functional/Tree/TokenTreeTestTrait.php, line 113

Class

TokenTreeTestTrait
Helper trait to assert tokens in token tree browser.

Namespace

Drupal\Tests\token\Functional\Tree

Code

protected function getXpathForTokenInTree($token, $parent = '') {
  $xpath = "//tr";
  if ($parent) {
    $xpath .= '[@data-tt-parent-id="token-' . $parent . '"]';
  }
  $xpath .= '/td[contains(@class, "token-key") and text() = "' . $token . '"]';
  return $xpath;
}