function TelephoneFieldTest::testTelephoneFormatter
Same name in other branches
- 9 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()
- 8.9.x core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()
- 11.x core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()
Tests the telephone formatter.
@covers \Drupal\telephone\Plugin\Field\FieldFormatter\TelephoneLinkFormatter::viewElements
File
-
core/
modules/ telephone/ tests/ src/ Functional/ TelephoneFieldTest.php, line 102
Class
- TelephoneFieldTest
- Tests the creation of telephone fields.
Namespace
Drupal\Tests\telephone\FunctionalCode
public function testTelephoneFormatter() : void {
$phone_numbers = [
'standard phone number' => [
'123456789',
'123456789',
],
'whitespace is removed' => [
'1234 56789',
'123456789',
],
'parse_url(0) return FALSE workaround' => [
'0',
'0-',
],
'php bug 70588 workaround - lower edge check' => [
'1',
'1-',
],
'php bug 70588 workaround' => [
'123',
'1-23',
],
'php bug 70588 workaround - with whitespace removal' => [
'1 2 3 4 5',
'1-2345',
],
'php bug 70588 workaround - upper edge check' => [
'65534',
'6-5534',
],
'php bug 70588 workaround - edge check' => [
'65535',
'6-5535',
],
'php bug 70588 workaround - invalid port number - lower edge check' => [
'65536',
'6-5536',
],
'php bug 70588 workaround - invalid port number - upper edge check' => [
'99999',
'9-9999',
],
'lowest number not affected by php bug 70588' => [
'100000',
'100000',
],
];
foreach ($phone_numbers as $data) {
[
$input,
$expected,
] = $data;
// Test basic entry of telephone field.
$edit = [
'title[0][value]' => $this->randomMachineName(),
'field_telephone[0][value]' => $input,
];
$this->drupalGet('node/add/article');
$this->submitForm($edit, 'Save');
$this->assertSession()
->responseContains('<a href="tel:' . $expected . '">');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.