getEntityTypeId() === "file") {
/** @var \Drupal\file\Entity\File $entity */
$href = file_create_url($entity->getFileUri());
}
else {
$href = $entity->toUrl()->toString();
}
$input = 'Link text';
$expected = 'Link text';
$this->assertSame($expected, $this->process($input, $langcode)->getProcessedText());
}
/**
* Asserts that Linkit filter correctly processes the content titles.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object to check.
* @param string $langcode
* The language code of the text to be filtered.
*/
protected function assertLinkitFilterWithTitle(EntityInterface $entity, $langcode = LanguageInterface::LANGCODE_SITE_DEFAULT) {
if ($entity->getEntityTypeId() === "file") {
/** @var \Drupal\file\Entity\File $entity */
$href = file_create_url($entity->getFileUri());
}
else {
$href = $entity->toUrl()->toString();
}
$input = 'Link text';
$expected = 'Link text';
$this->assertSame($expected, $this->process($input, $langcode)->getProcessedText());
}
/**
* Test helper method that wraps the filter process method.
*
* @param string $input
* The text string to be filtered.
* @param string $langcode
* The language code of the text to be filtered.
*
* @return \Drupal\filter\FilterProcessResult
* The filtered text, wrapped in a FilterProcessResult object, and possibly
* with associated assets, cacheability metadata and placeholders.
*
* @see \Drupal\filter\Plugin\FilterInterface::process
*/
protected function process($input, $langcode = LanguageInterface::LANGCODE_SITE_DEFAULT) {
return $this->filter->process($input, $langcode);
}
}