You are here

public function NodeMatcherTest::testNodeMatcherWidthMetadataTokens in Linkit 8.5

Tests node matcher with tokens in the matcher metadata.

File

tests/src/Kernel/Matchers/NodeMatcherTest.php, line 165

Class

NodeMatcherTest
Tests node matcher.

Namespace

Drupal\Tests\linkit\Kernel\Matchers

Code

public function testNodeMatcherWidthMetadataTokens() {

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

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