protected function AssertLinkitFilterTrait::assertLinkitFilter in Linkit 8.5
Asserts that Linkit filter correctly processes the content.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object to check.
string $langcode: The language code of the text to be filtered.
2 calls to AssertLinkitFilterTrait::assertLinkitFilter()
- LinkitFilterEntityTest::testFilterEntityTranslations in tests/
src/ Kernel/ LinkitFilterEntityTest.php - Tests the linkit filter for entities with translations.
- LinkitFilterEntityTest::testFilterFileEntity in tests/
src/ Kernel/ LinkitFilterEntityTest.php - Tests the linkit filter for file entities.
File
- tests/
src/ Kernel/ AssertLinkitFilterTrait.php, line 29
Class
- AssertLinkitFilterTrait
- Provides helper methods for assertions.
Namespace
Drupal\Tests\linkit\KernelCode
protected function assertLinkitFilter(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 = '<a data-entity-type="' . $entity
->getEntityTypeId() . '" data-entity-uuid="' . $entity
->uuid() . '">Link text</a>';
$expected = '<a data-entity-type="' . $entity
->getEntityTypeId() . '" data-entity-uuid="' . $entity
->uuid() . '" href="' . $href . '">Link text</a>';
$this
->assertSame($expected, $this
->process($input, $langcode)
->getProcessedText());
}