You are here

public function TermMatcherTest::testTermMatcherWidthMetadataTokens in Linkit 8.5

Tests term matcher with tokens in the matcher metadata.

File

tests/src/Kernel/Matchers/TermMatcherTest.php, line 88

Class

TermMatcherTest
Tests term matcher.

Namespace

Drupal\Tests\linkit\Kernel\Matchers

Code

public function testTermMatcherWidthMetadataTokens() {

  /** @var \Drupal\linkit\MatcherInterface $plugin */
  $plugin = $this->manager
    ->createInstance('entity:taxonomy_term', [
    'settings' => [
      'metadata' => '[term:tid] [term:field_with_no_value]',
    ],
  ]);
  $suggestionCollection = $plugin
    ->execute('Lorem');

  /** @var \Drupal\linkit\Suggestion\EntitySuggestion[] $suggestions */
  $suggestions = $suggestionCollection
    ->getSuggestions();
  foreach ($suggestions as $suggestion) {
    $this
      ->assertStringNotContainsString('[term:nid]', $suggestion
      ->getDescription(), 'Raw token "[term:nid]" is not present in the description');
    $this
      ->assertStringNotContainsString('[term:field_with_no_value]', $suggestion
      ->getDescription(), 'Raw token "[term:field_with_no_value]" is not present in the description');
  }
}