public function SmsFrameworkPhoneNumberWidgetTest::testPhoneNumberNotPurgedFieldValueOnExpiration in SMS Framework 8
Same name and namespace in other branches
- 2.x tests/src/Functional/SmsFrameworkPhoneNumberWidgetTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberWidgetTest::testPhoneNumberNotPurgedFieldValueOnExpiration()
- 2.1.x tests/src/Functional/SmsFrameworkPhoneNumberWidgetTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberWidgetTest::testPhoneNumberNotPurgedFieldValueOnExpiration()
Test behaviour of widget with phone number purge setting.
File
- tests/
src/ Functional/ SmsFrameworkPhoneNumberWidgetTest.php, line 134
Class
- SmsFrameworkPhoneNumberWidgetTest
- Tests phone numbers.
Namespace
Drupal\Tests\sms\FunctionalCode
public function testPhoneNumberNotPurgedFieldValueOnExpiration() {
$phone_number_settings = $this
->createPhoneNumberSettings('entity_test', 'entity_test');
$phone_number_settings
->setPurgeVerificationPhoneNumber(FALSE)
->save();
$test_entity = $this
->createEntityWithPhoneNumber($phone_number_settings, [
'+123123123',
]);
// Force verification code to expire.
$this
->getLastVerification()
->set('created', time() - ($phone_number_settings
->getVerificationCodeLifetime() + 1))
->save();
$this
->cronRun();
// Ensure phone number value is still on the field.
$this
->drupalGet($test_entity
->toUrl('edit-form'));
$t_args = [
'@url' => Url::fromRoute('sms.phone.verify')
->toString(),
'@time' => '1 hour',
];
$this
->assertRaw(t('Save this form to send a new verification code as an SMS message, you must enter the code into the <a href="@url">verification form</a> within @time.', $t_args));
$field_phone_number = $phone_number_settings
->getFieldName('phone_number');
$this
->assertFieldByName($field_phone_number . '[0][value]', '+123123123');
}