You are here

public function FileMatcherTest::testTermMatcherWidthMetadataTokens in Linkit 8.5

Tests file matcher with tokens in the matcher metadata.

File

tests/src/Kernel/Matchers/FileMatcherTest.php, line 95

Class

FileMatcherTest
Tests file matcher.

Namespace

Drupal\Tests\linkit\Kernel\Matchers

Code

public function testTermMatcherWidthMetadataTokens() {

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

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