You are here

public function LinkitFilterEntityTest::testQueryAndFragments in Linkit 8.5

Tests that the linkit filter do not overwrite provided fragment and query.

File

tests/src/Kernel/LinkitFilterEntityTest.php, line 157

Class

LinkitFilterEntityTest
Tests the Linkit filter.

Namespace

Drupal\Tests\linkit\Kernel

Code

public function testQueryAndFragments() {

  // Create an entity.
  $entity = EntityTest::create([
    'name' => $this
      ->randomMachineName(),
  ]);
  $entity
    ->save();

  // Make sure original query and fragment are preserved.
  $input = '<a data-entity-type="' . $entity
    ->getEntityTypeId() . '" data-entity-uuid="' . $entity
    ->uuid() . '" href="unimportant/1234?query=string#fragment">Link text</a>';
  $this
    ->assertStringContainsString('?query=string', $this
    ->process($input)
    ->getProcessedText());
  $this
    ->assertStringContainsString('#fragment', $this
    ->process($input)
    ->getProcessedText());
}