public function FixedTextLinkTest::testFormatsWithConfiguredText in Fixed text link formatter 8
Tests that the link is formatted with the configured options.
File
- tests/
src/ Functional/ FixedTextLinkTest.php, line 89
Class
- FixedTextLinkTest
- Tests the correct function of the Fixed Text Link formatter.
Namespace
Drupal\Tests\fixed_text_link_formatter\FunctionalCode
public function testFormatsWithConfiguredText() {
$linkText = 'View our amazing website';
$linkClass = 'test-class';
$this->entityDisplayRepository
->getViewDisplay('node', $this->nodeType
->id(), 'full')
->setComponent($this->linkFieldName, [
'type' => 'fixed_text_link',
'settings' => [
'link_text' => $linkText,
'link_class' => $linkClass,
],
])
->save();
$node = $this
->createNode([
'type' => $this->nodeType
->id(),
$this->linkFieldName => [
'uri' => 'http://example.com/test',
],
]);
$this
->getSession()
->visit($node
->toUrl()
->toString());
$this
->assertSession()
->linkExists($linkText);
$this
->assertSession()
->elementExists('css', ".{$linkClass}");
}