protected function AssertLinkitFilterTrait::assertLinkitFilterWithTitle in Linkit 8.5
Asserts that Linkit filter correctly processes the content titles.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object to check.
string $langcode: The language code of the text to be filtered.
3 calls to AssertLinkitFilterTrait::assertLinkitFilterWithTitle()
- LinkitFilterEntityTest::testFilterEntityAccess in tests/
src/ Kernel/ LinkitFilterEntityTest.php - Tests the linkit filter for entities with different access.
- 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 51
Class
- AssertLinkitFilterTrait
- Provides helper methods for assertions.
Namespace
Drupal\Tests\linkit\KernelCode
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 = '<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 . '" title="' . Html::decodeEntities($entity
->label()) . '">Link text</a>';
$this
->assertSame($expected, $this
->process($input, $langcode)
->getProcessedText());
}