WebformElementTelephoneTest.php in Webform 8.5
File
tests/src/Functional/Element/WebformElementTelephoneTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Element;
class WebformElementTelephoneTest extends WebformElementBrowserTestBase {
public static $modules = [
'webform',
'telephone_validation',
];
protected static $testWebforms = [
'test_element_telephone',
];
public function setUp() {
if (floatval(\Drupal::VERSION) >= 9) {
$this
->markTestSkipped('Issue #3110478: [Webform 8.x-6.x] Track the D9 readiness state of the Webform module\'s (optional) dependencies');
}
parent::setUp();
}
public function testTelephone() {
$this
->drupalGet('/webform/test_element_telephone');
$this
->assertRaw('<input data-drupal-selector="edit-tel-default" type="tel" id="edit-tel-default" name="tel_default" value="" size="30" maxlength="128" class="form-tel" />');
$this
->assertRaw('<input class="js-webform-telephone-international webform-webform-telephone-international form-tel" data-drupal-selector="edit-tel-international" type="tel" id="edit-tel-international" name="tel_international" value="" size="30" maxlength="128" />');
$this
->assertRaw('<input data-drupal-selector="edit-tel-validation-e164" type="tel" id="edit-tel-validation-e164" name="tel_validation_e164" value="" size="30" maxlength="128" class="form-tel" />');
$this
->assertRaw('<input data-drupal-selector="edit-tel-validation-national" aria-describedby="edit-tel-validation-national--description" type="tel" id="edit-tel-validation-national" name="tel_validation_national" value="" size="30" maxlength="128" class="form-tel" />');
$edit = [
'tel_validation_e164' => '12024561111',
'tel_validation_national' => '12024561111',
];
$this
->drupalPostForm('/webform/test_element_telephone', $edit, 'Submit');
$this
->assertRaw('The phone number <em class="placeholder">12024561111</em> is not valid.');
$edit = [
'tel_validation_e164' => '+12024561111',
'tel_validation_national' => '+12024561111',
];
$this
->drupalPostForm('/webform/test_element_telephone', $edit, 'Submit');
$this
->assertNoRaw('The phone number <em class="placeholder">12024561111</em> is not valid.');
$edit = [
'tel_validation_national' => '+74956970349',
];
$this
->drupalPostForm('/webform/test_element_telephone', $edit, 'Submit');
$this
->assertRaw('The phone number <em class="placeholder">+74956970349</em> is not valid.');
}
}