protected function FieldFormatterTest::generateTelephoneField in Telephone Formatter 8
Helper method for telephone field generation.
1 call to FieldFormatterTest::generateTelephoneField()
- FieldFormatterTest::testTelephoneFieldFallback in tests/
src/ Functional/ FieldFormatterTest.php - Test function for testTelephoneField().
File
- tests/
src/ Functional/ FieldFormatterTest.php, line 67
Class
- FieldFormatterTest
- Tests the creation of telephone fields.
Namespace
Drupal\Tests\telephone_formatter\FunctionalCode
protected function generateTelephoneField($settings = []) {
// Add the telephone field to the article content type.
FieldStorageConfig::create([
'field_name' => 'field_telephone',
'entity_type' => 'node',
'type' => 'telephone',
])
->save();
FieldConfig::create([
'field_name' => 'field_telephone',
'label' => 'Telephone Number',
'entity_type' => 'node',
'bundle' => 'page',
])
->save();
\Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load('node.page.default')
->setComponent('field_telephone', [
'type' => 'telephone_formatter',
'weight' => 1,
'settings' => [
'format' => $settings['format'],
'link' => $settings['link'],
'default_country' => $settings['default_country'],
],
])
->save();
}