public function SmsFrameworkPhoneNumberAdminTest::testPhoneNumberFieldExisting in SMS Framework 8
Same name and namespace in other branches
- 2.x tests/src/FunctionalJavascript/SmsFrameworkPhoneNumberAdminTest.php \Drupal\Tests\sms\FunctionalJavascript\SmsFrameworkPhoneNumberAdminTest::testPhoneNumberFieldExisting()
- 2.1.x tests/src/FunctionalJavascript/SmsFrameworkPhoneNumberAdminTest.php \Drupal\Tests\sms\FunctionalJavascript\SmsFrameworkPhoneNumberAdminTest::testPhoneNumberFieldExisting()
Test using existing fields for new phone number settings.
File
- tests/
src/ FunctionalJavascript/ SmsFrameworkPhoneNumberAdminTest.php, line 51
Class
- SmsFrameworkPhoneNumberAdminTest
- Tests phone number administration user interface.
Namespace
Drupal\Tests\sms\FunctionalJavascriptCode
public function testPhoneNumberFieldExisting() {
$field_storage = $this->entityTypeManager
->getStorage('field_storage_config');
$field_instance = $this->entityTypeManager
->getStorage('field_config');
// Create a field so it appears as a pre-existing field.
/** @var \Drupal\field\FieldStorageConfigInterface $field_telephone */
$field_telephone = $field_storage
->create([
'entity_type' => 'entity_test',
'field_name' => Unicode::strtolower($this
->randomMachineName()),
'type' => 'telephone',
]);
$field_telephone
->save();
$field_instance
->create([
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'field_name' => $field_telephone
->getName(),
])
->save();
$this
->drupalGet('admin/config/smsframework/phone_number/add');
$session = $this
->assertSession();
$session
->selectExists('entity_bundle')
->selectOption('entity_test|entity_test');
$session
->waitForElement('xpath', '//option[@value="' . $field_telephone
->getName() . '"]');
$session
->selectExists('field_mapping[phone_number]')
->selectOption($field_telephone
->getName());
$session
->buttonExists('Save')
->click();
$this
->drupalGet('admin/config/smsframework/phone_number/entity_test.entity_test');
$session
->statusCodeEquals(200);
$session
->optionExists('edit-field-mapping-phone-number', $field_telephone
->getName())
->hasAttribute('selected');
}