protected function TelephoneFieldTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::setUp()
Overrides BrowserTestBase::setUp
File
- core/
modules/ telephone/ tests/ src/ Functional/ TelephoneFieldTest.php, line 42
Class
- TelephoneFieldTest
- Tests the creation of telephone fields.
Namespace
Drupal\Tests\telephone\FunctionalCode
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
]);
$this->webUser = $this
->drupalCreateUser([
'create article content',
'edit own article content',
]);
$this
->drupalLogin($this->webUser);
// 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' => 'article',
])
->save();
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$display_repository
->getFormDisplay('node', 'article')
->setComponent('field_telephone', [
'type' => 'telephone_default',
'settings' => [
'placeholder' => '123-456-7890',
],
])
->save();
$display_repository
->getViewDisplay('node', 'article')
->setComponent('field_telephone', [
'type' => 'telephone_link',
'weight' => 1,
])
->save();
}