function TelephoneFieldTest::testTelephoneFormatter

Same name in other branches
  1. 9 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()
  2. 10 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()
  3. 11.x core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneFormatter()

Test the telephone formatter.

@covers \Drupal\telephone\Plugin\Field\FieldFormatter\TelephoneLinkFormatter::viewElements

@dataProvider providerPhoneNumbers

File

core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php, line 102

Class

TelephoneFieldTest
Tests the creation of telephone fields.

Namespace

Drupal\Tests\telephone\Functional

Code

public function testTelephoneFormatter($input, $expected) {
    // Test basic entry of telephone field.
    $edit = [
        'title[0][value]' => $this->randomMachineName(),
        'field_telephone[0][value]' => $input,
    ];
    $this->drupalPostForm('node/add/article', $edit, t('Save'));
    $this->assertRaw('<a href="tel:' . $expected . '">');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.