function TelephoneFieldTest::testTelephoneFormatter

Same name in other branches
  1. 8.9.x 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()

Tests the telephone formatter.

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

@dataProvider providerPhoneNumbers

File

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

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->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.