public function FixedTextLinkTest::setUp in Fixed text link formatter 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ FixedTextLinkTest.php, line 52
Class
- FixedTextLinkTest
- Tests the correct function of the Fixed Text Link formatter.
Namespace
Drupal\Tests\fixed_text_link_formatter\FunctionalCode
public function setUp() {
parent::setUp();
$this->entityDisplayRepository = $this->container
->get('entity_display.repository');
$this->nodeType = $this
->drupalCreateContentType();
$this->linkFieldName = mb_strtolower($this
->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this->linkFieldName,
'entity_type' => 'node',
'type' => 'link',
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => $this->nodeType
->id(),
'settings' => [
'title' => DRUPAL_DISABLED,
'link_type' => LinkItemInterface::LINK_GENERIC,
],
]);
$this->field
->save();
$this->entityDisplayRepository
->getFormDisplay('node', $this->nodeType
->id(), 'default')
->setComponent($this->linkFieldName, [
'type' => 'link_default',
'settings' => [
'placeholder_url' => 'http://example.com',
],
])
->save();
}