public function SmsFrameworkPhoneNumberAdminTest::testPhoneNumberCrud in SMS Framework 2.1.x
Same name and namespace in other branches
- 8 tests/src/Functional/SmsFrameworkPhoneNumberAdminTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberAdminTest::testPhoneNumberCrud()
- 2.x tests/src/Functional/SmsFrameworkPhoneNumberAdminTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberAdminTest::testPhoneNumberCrud()
CRUD a phone number settings via UI.
File
- tests/
src/ Functional/ SmsFrameworkPhoneNumberAdminTest.php, line 99
Class
- SmsFrameworkPhoneNumberAdminTest
- Tests phone number administration user interface.
Namespace
Drupal\Tests\sms\FunctionalCode
public function testPhoneNumberCrud() {
// Add a new phone number config.
$this
->drupalGet('admin/config/smsframework/phone_number/add');
$this
->assertResponse(200);
$edit = [
'entity_bundle' => 'entity_test|entity_test',
'field_mapping[phone_number]' => '!create',
];
$this
->drupalPostForm('admin/config/smsframework/phone_number/add', $edit, t('Save'));
$this
->assertUrl('admin/config/smsframework/phone_number');
$t_args = [
'%id' => 'entity_test.entity_test',
];
$this
->assertRaw(t('Phone number settings %id created.', $t_args));
$this
->assertRaw('<td>entity_test</td>
<td>entity_test</td>', 'Phone number settings displayed as row.');
$this
->assertLinkByHref('admin/config/smsframework/phone_number/entity_test.entity_test');
$this
->assertLinkByHref('admin/config/smsframework/phone_number/entity_test.entity_test/delete');
// Ensure a phone number config cannot have the same bundle as pre-existing.
$this
->drupalGet('admin/config/smsframework/phone_number/add');
$this
->assertNoOption('edit-entity-bundle', 'entity_test|entity_test');
// Edit phone number settings.
$this
->drupalGet('admin/config/smsframework/phone_number/entity_test.entity_test');
$this
->assertField('field_mapping[phone_number]', 'Phone number field exists.');
$this
->assertNoField('entity_bundle', 'Bundle field does not exist.');
$this
->assertOptionSelected('edit-field-mapping-phone-number', 'phone_number');
// Ensure edit form is saving correctly.
$edit = [
'code_lifetime' => '7777',
];
$this
->drupalPostForm('admin/config/smsframework/phone_number/entity_test.entity_test', $edit, t('Save'));
$this
->assertEqual(7777, $this
->config('sms.phone.entity_test.entity_test')
->get('verification_code_lifetime'));
// Delete new phone number settings.
$this
->drupalGet('admin/config/smsframework/phone_number/entity_test.entity_test/delete');
$this
->assertRaw(t('Are you sure you want to delete SMS phone number settings %label?', [
'%label' => 'entity_test.entity_test',
]));
$this
->drupalPostForm('admin/config/smsframework/phone_number/entity_test.entity_test/delete', [], t('Delete'));
$this
->assertUrl('admin/config/smsframework/phone_number');
$this
->assertRaw(t('Phone number settings %label was deleted.', [
'%label' => 'entity_test.entity_test',
]));
$this
->assertRaw('No phone number settings found.');
}