public function SmsFrameworkPhoneNumberAdminTest::testPhoneNumberFieldCreate in SMS Framework 8
Same name and namespace in other branches
- 2.x tests/src/Functional/SmsFrameworkPhoneNumberAdminTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberAdminTest::testPhoneNumberFieldCreate()
- 2.1.x tests/src/Functional/SmsFrameworkPhoneNumberAdminTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberAdminTest::testPhoneNumberFieldCreate()
Test field creation for new phone number settings.
File
- tests/
src/ Functional/ SmsFrameworkPhoneNumberAdminTest.php, line 149
Class
- SmsFrameworkPhoneNumberAdminTest
- Tests phone number administration user interface.
Namespace
Drupal\Tests\sms\FunctionalCode
public function testPhoneNumberFieldCreate() {
$field_name_telephone = 'phone_number';
// Test the unique field name generator by creating pre-existing fields.
$field_storage = $this->entityTypeManager
->getStorage('field_storage_config');
$field_storage
->create([
'entity_type' => 'entity_test',
'field_name' => $field_name_telephone,
'type' => 'telephone',
])
->save();
$edit = [
'entity_bundle' => 'entity_test|entity_test',
'field_mapping[phone_number]' => '!create',
];
$this
->drupalPostForm('admin/config/smsframework/phone_number/add', $edit, t('Save'));
$field_name_telephone .= '_2';
$field_config = $field_storage
->load('entity_test.' . $field_name_telephone);
$this
->assertTrue($field_config instanceof FieldStorageConfigInterface, 'Field config created.');
// Ensure field name is associated with config.
$this
->drupalGet('admin/config/smsframework/phone_number/entity_test.entity_test');
$this
->assertResponse(200);
$this
->assertOptionSelected('edit-field-mapping-phone-number', $field_name_telephone);
}